Operators and Expressions # MCQs Practice set

Q.1 What is the output of the expression: 5 + 3 * 2?

16
11
10
13
Explanation - Multiplication has higher precedence than addition, so 3*2=6, then 5+6=11.
Correct answer is: 11

Q.2 What is the result of the expression: 10 / 3 in integer division?

3
3.33
4
10
Explanation - Integer division discards the fractional part. 10/3 = 3 with remainder 1.
Correct answer is: 3

Q.3 Which operator has the highest precedence in C?

*
+
=
++
Explanation - The increment operator (++) has higher precedence than multiplication, addition, or assignment.
Correct answer is: ++

Q.4 What will be the output of: int x = 5; x += 3; print(x);

5
3
8
15
Explanation - The '+=' operator adds the right-hand side to the variable: x = x + 3, so x becomes 8.
Correct answer is: 8

Q.5 What is the value of expression: 7 % 3?

2
1
0
3
Explanation - The modulus operator '%' gives the remainder after division. 7/3 has remainder 1.
Correct answer is: 1

Q.6 Which of the following is a logical operator in C?

&&
++
%
&
Explanation - '&&' represents logical AND. '&' is bitwise AND, '++' is increment, '%' is modulus.
Correct answer is: &&

Q.7 What is the result of: 4 | 2 (bitwise OR)?

6
2
0
4
Explanation - Bitwise OR compares each bit: 4(100) | 2(010) = 110 which is 6 in decimal.
Correct answer is: 6

Q.8 Evaluate: 8 & 3 (bitwise AND).

8
0
3
11
Explanation - 8(1000) & 3(0011) = 0000 = 0 in decimal.
Correct answer is: 0

Q.9 What is the output of: int x = 10; int y = ++x;

9
10
11
Error
Explanation - Prefix increment increases x before assignment. x becomes 11, then assigned to y.
Correct answer is: 11

Q.10 If x = 5 and y = 2, what is x / y in C?

2
2.5
3
0
Explanation - Both x and y are integers; integer division truncates decimal part, so 5/2 = 2.
Correct answer is: 2

Q.11 What does the expression: !(5 > 3) evaluate to?

true
false
5
3
Explanation - 5 > 3 is true; logical NOT (!) inverts it, so result is false.
Correct answer is: false

Q.12 Which operator is used to check equality in C?

=
==
===
!
Explanation - '==' is the equality operator; '=' is assignment.
Correct answer is: ==

Q.13 What is the output of: 2 << 3?

16
8
4
2
Explanation - Left shift (<<) moves bits to the left: 2(10) << 3 = 10000 = 16.
Correct answer is: 16

Q.14 What is the value of: 15 >> 2?

3
4
7
2
Explanation - Right shift (>>) moves bits to the right: 15(1111) >> 2 = 0011 = 3.
Correct answer is: 3

Q.15 Which expression evaluates to true if x is between 5 and 10 (inclusive)?

x > 5 && x < 10
x >= 5 && x <= 10
x > 5 || x < 10
x == 5 && x == 10
Explanation - The correct range includes both boundaries using >= and <= with logical AND.
Correct answer is: x >= 5 && x <= 10

Q.16 What is the output of: 10 % 2 == 0 ? 'Even' : 'Odd';

Even
Odd
10
2
Explanation - 10 % 2 == 0 is true, so ternary operator returns 'Even'.
Correct answer is: Even

Q.17 Which operator is used for bitwise XOR?

^
&
|
~
Explanation - '^' performs bitwise XOR (exclusive OR) between two numbers.
Correct answer is: ^

Q.18 What is the value of: 3 + 4 * 2 / (1 - 5) % 2?

1
3
0
2
Explanation - Step by step: 1-5=-4; 4*2=8; 8/(-4)=-2; -2%2=0; 3+0=3.
Correct answer is: 3

Q.19 What is the result of: 1 && 0 || 1?

0
1
Error
2
Explanation - Logical AND has higher precedence: 1 && 0 = 0; then 0 || 1 = 1.
Correct answer is: 1

Q.20 Which statement is correct about assignment operators?

They return no value
They return the assigned value
They can only be used with integers
They are only for floats
Explanation - In C and most languages, assignment operators return the value assigned, allowing chaining.
Correct answer is: They return the assigned value

Q.21 Evaluate: ~5 in C (bitwise NOT).

-6
6
5
-5
Explanation - Bitwise NOT inverts all bits: ~5 = -6 in two's complement representation.
Correct answer is: -6

Q.22 Which expression increments x by 1?

x + 1
x++
x--
x += 2
Explanation - x++ increases x by 1 after current operation; x += 1 would also work but is not listed.
Correct answer is: x++

Q.23 What is the value of: 0 || 0 && 1?

0
1
Error
Undefined
Explanation - Logical AND has higher precedence: 0 && 1 = 0; 0 || 0 = 0.
Correct answer is: 0

Q.24 Which of the following is a ternary operator?

?:
&&
||
++
Explanation - The ternary operator 'condition ? expr1 : expr2' returns one of two values based on a condition.
Correct answer is: ?: