Practice 40 Operators multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.
Show Answer & Explanation
Correct Answer: D — Unary
Unary operators have higher precedence than arithmetic and relational operators.
What will be the output?
int x = 5;
printf("%d", x++);Show Answer & Explanation
Correct Answer: B — 5
Post-increment prints the value first, then increments.
What will be the output?
int x = 5;
printf("%d", ++x);Show Answer & Explanation
Correct Answer: C — 6
Pre-increment increments the value first, then prints.
Show Answer & Explanation
Correct Answer: B — ==
== compares two values for equality.
What is the output?
printf("%d", 10 > 5 && 3 < 1);Show Answer & Explanation
Correct Answer: A — 0
10 > 5 is true, 3 < 1 is false, so true && false = false (0).
Show Answer & Explanation
Correct Answer: B — &
& performs bitwise AND operation.
What will be the output?
printf("%d", 5 & 3);Show Answer & Explanation
Correct Answer: A — 1
5 (101) & 3 (011) = 001 which is 1.
Show Answer & Explanation
Correct Answer: C — =
= assigns value to a variable.
What will be the output?
printf("%d", 10 / 4);Show Answer & Explanation
Correct Answer: A — 2
Integer division truncates decimal part.
Show Answer & Explanation
Correct Answer: C — =
Assignment operator has right-to-left associativity.
What is the output?
int a = 10, b = 20;
printf("%d", a > b ? a : b);Show Answer & Explanation
Correct Answer: B — 20
Ternary operator returns the larger value.
Show Answer & Explanation
Correct Answer: A — ?:
?: takes three operands.
What will be the output?
printf("%d", 5 | 3);Show Answer & Explanation
Correct Answer: D — 7
5 (101) | 3 (011) = 111 which is 7.
Show Answer & Explanation
Correct Answer: B — ~
~ performs bitwise NOT operation.
What will be the output?
printf("%d", !0);Show Answer & Explanation
Correct Answer: B — 1
!0 is logical NOT of false, resulting in true (1).
Show Answer & Explanation
Correct Answer: B — ->
-> is used to access members via pointer.
What is the output?
printf("%d", 8 >> 2);Show Answer & Explanation
Correct Answer: B — 2
Right shift by 2 divides by 4.
Show Answer & Explanation
Correct Answer: B — &
& returns address of variable.
What will be the output?
printf("%d", 5 ^ 3);Show Answer & Explanation
Correct Answer: A — 6
5 (101) XOR 3 (011) = 110 which is 6.
Show Answer & Explanation
Correct Answer: C — =
Assignment operator has lower precedence than arithmetic operators.
What will be the output?
int a = 5, b = 10;
printf("%d", a + b * 2);Show Answer & Explanation
Correct Answer: B — 25
Multiplication has higher precedence than addition: 10*2 + 5 = 25.
What will be the output?
printf("%d", (5 + 10) * 2);Show Answer & Explanation
Correct Answer: B — 30
Parentheses have highest precedence.
Show Answer & Explanation
Correct Answer: B — &&
&& is logical AND operator.
What will be the output?
int x = 1;
printf("%d", x++ + ++x);Show Answer & Explanation
Correct Answer: C — Undefined
Modifying variable more than once between sequence points leads to undefined behavior.
What will be the output?
printf("%d", 0 || 5);Show Answer & Explanation
Correct Answer: B — 1
Logical OR returns 1 if any operand is true.
Show Answer & Explanation
Correct Answer: B — |
Bitwise OR combines bits.
What will be the output?
printf("%d", ~1);Show Answer & Explanation
Correct Answer: B — -2
~1 inverts all bits; result depends on two's complement representation.
Show Answer & Explanation
Correct Answer: D — =
Assignment operator has the lowest precedence.
What will be the output?
int a = 10;
printf("%d", a += 5);Show Answer & Explanation
Correct Answer: B — 15
a += 5 is equivalent to a = a + 5.
Show Answer & Explanation
Correct Answer: D — ==
== is a relational operator, not assignment.
What will be the output?
printf("%d", 5 << 1);Show Answer & Explanation
Correct Answer: B — 10
Left shift by 1 multiplies by 2.
Show Answer & Explanation
Correct Answer: B — *
* dereferences a pointer.
What will be the output?
int a = 0;
printf("%d", !a);Show Answer & Explanation
Correct Answer: B — 1
Logical NOT of 0 is 1.
Show Answer & Explanation
Correct Answer: C — !=
!= checks not equal condition.
What will be the output?
printf("%d", 4 & 1);Show Answer & Explanation
Correct Answer: A — 0
4 (100) & 1 (001) = 000.
Show Answer & Explanation
Correct Answer: C — =
Assignment operator has right-to-left associativity.
What will be the output?
printf("%d", 10 % 3);Show Answer & Explanation
Correct Answer: A — 1
Modulus operator returns remainder.
Show Answer & Explanation
Correct Answer: B — ,
Comma operator evaluates expressions left to right.
What will be the output?
printf("%d", (5 > 3) + (2 > 4));Show Answer & Explanation
Correct Answer: B — 1
True is 1 and false is 0 → 1 + 0 = 1.
Show Answer & Explanation
Correct Answer: C — ++
++ operates on a single operand.