Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz on C Operators

Total questions: 15

Worksheet time: 7mins

Name
Class
Date
1.

int x;

int y;

int z;

x=3;

y=4;

z = ++x * y++;

printf("%d",z);

a)

12

b)

16

c)

20

d)

0

2.

Which operator is used to compare two values for equality?

a)

<>

b)

=

c)

!=

d)

==

3.

What is the output of the expression (5 > 3) && (2 < 4)?

a)

undefined

b)

true

c)

false

d)

null

4.

What does the bitwise operator '&' do in C?

a)

The '&' operator shifts bits to the left.

b)

The '&' operator inverts the bits of a number.

c)

The '&' operator performs a bitwise AND operation.

d)

The '&' operator performs a bitwise OR operation.

5.

How do you assign a value to a variable in C?

a)

You can assign a value to a variable in C by using the command: set variable_name to value;

b)

You assign a value to a variable in C using the syntax: variable_name = value;.

c)

In C, you declare a variable and assign a value with the syntax: variable_name : value;

d)

You assign a value to a variable in C using the syntax: value = variable_name;

6.

#include <stdio.h>

int main()

{

int i = 95;

char c = 97;

printf("%d, %d\n", sizeof(i), sizeof(c));

return 0;

}

a)

4,1

b)

4,2

c)

2,4

d)

2,8

7.

How do you determine the size of a data type in C?

a)

Use the 'sizeof' operator.

b)

Use the 'length' function.

c)

Check the data type documentation.

d)

Use the 'size' keyword.

8.

What is the result of the expression 10 & 4?

a)

14

b)

0

c)

8

d)

6

9.

Which operator is used to access the value pointed to by a pointer?

a)

@

b)

->

c)

*

d)

&

10.

#include <stdio.h>

void main()

{

int x = 5 * 9 / 3 + 9;

printf ("%d",x);

}

a)

24

b)

3

c)

23

d)

34

11.

if x is initially 7, What is the output of following statements?

'printf("%d", ++x);'

'printf("%d", x++);'

a)

7, 8

b)

6,7

c)

8, 9

d)

8, 8

12.

int x = 15;

(x>0)?printf("x is greater"):printf("x having negative values")

Find the Output.

a)

Error

b)

x is greater

c)

x having negative values

d)

None of these

13.

What is the result of the expression (1 || 0)?

a)

0

b)

1

c)

true

d)

undefined

14.

What is the output of the following code snippet:

int a=12;

a?printf("GEC"):printf("IT");

a)

GEC

b)

IT

c)

GEC IT

d)

Nothing printed

15.

Explain the difference between pre-increment and post-increment operators in C.

a)

Pre-increment and post-increment are the same.

b)

Pre-increment returns first, then increments the value.

Post-increment increments first, then returns the value.

c)

Pre-increment decrements first, then returns the value.

Post-increment returns first, then increments the value.

d)

Pre-increment increments first, then returns the value.

Post-increment returns first, then increments the value.