C Programming

Operators — Practice MCQs for CCAT

40 Questions Section B: Programming C Programming

Practice 40 Operators multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.

Q1.
Which operator has the highest precedence in C?
AArithmetic
BRelational
CAssignment
DUnary
Show Answer & Explanation

Correct Answer: D — Unary

Unary operators have higher precedence than arithmetic and relational operators.

Q2.

What will be the output?


int x = 5;
printf("%d", x++);
A4
B5
C6
DError
Show Answer & Explanation

Correct Answer: B — 5

Post-increment prints the value first, then increments.

Q3.

What will be the output?


int x = 5;
printf("%d", ++x);
A4
B5
C6
DError
Show Answer & Explanation

Correct Answer: C — 6

Pre-increment increments the value first, then prints.

Q4.
Which operator is used to check equality?
A=
B==
C!=
D<=
Show Answer & Explanation

Correct Answer: B — ==

== compares two values for equality.

Q5.

What is the output?


printf("%d", 10 > 5 && 3 < 1);
A0
B1
CTrue
DFalse
Show Answer & Explanation

Correct Answer: A — 0

10 > 5 is true, 3 < 1 is false, so true && false = false (0).

Q6.
Which operator is used for bitwise AND?
A&&
B&
C|
D^
Show Answer & Explanation

Correct Answer: B — &

& performs bitwise AND operation.

Q7.

What will be the output?


printf("%d", 5 & 3);
A1
B3
C5
D7
Show Answer & Explanation

Correct Answer: A — 1

5 (101) & 3 (011) = 001 which is 1.

Q8.
Which operator is used to assign value?
A==
B:
C=
D->
Show Answer & Explanation

Correct Answer: C — =

= assigns value to a variable.

Q9.

What will be the output?


printf("%d", 10 / 4);
A2
B2.5
C3
DCompilation error
Show Answer & Explanation

Correct Answer: A — 2

Integer division truncates decimal part.

Q10.
Which operator has right-to-left associativity?
A+
B*
C=
D&&
Show Answer & Explanation

Correct Answer: C — =

Assignment operator has right-to-left associativity.

Q11.

What is the output?


int a = 10, b = 20;
printf("%d", a > b ? a : b);
A10
B20
C0
DError
Show Answer & Explanation

Correct Answer: B — 20

Ternary operator returns the larger value.

Q12.
Which operator is known as ternary operator?
A?:
B&&
C||
D::
Show Answer & Explanation

Correct Answer: A — ?:

?: takes three operands.

Q13.

What will be the output?


printf("%d", 5 | 3);
A1
B3
C5
D7
Show Answer & Explanation

Correct Answer: D — 7

5 (101) | 3 (011) = 111 which is 7.

Q14.
Which operator is used to invert bits?
A!
B~
C^
D&
Show Answer & Explanation

Correct Answer: B — ~

~ performs bitwise NOT operation.

Q15.

What will be the output?


printf("%d", !0);
A0
B1
CTrue
DError
Show Answer & Explanation

Correct Answer: B — 1

!0 is logical NOT of false, resulting in true (1).

Q16.
Which operator is used to access structure members using pointer?
A.
B->
C*
D&
Show Answer & Explanation

Correct Answer: B — ->

-> is used to access members via pointer.

Q17.

What is the output?


printf("%d", 8 >> 2);
A1
B2
C4
D8
Show Answer & Explanation

Correct Answer: B — 2

Right shift by 2 divides by 4.

Q18.
Which operator is used to get address of variable?
A*
B&
C#
D%
Show Answer & Explanation

Correct Answer: B — &

& returns address of variable.

Q19.

What will be the output?


printf("%d", 5 ^ 3);
A6
B8
C1
D7
Show Answer & Explanation

Correct Answer: A — 6

5 (101) XOR 3 (011) = 110 which is 6.

Q20.
Which of the following has lowest precedence?
A*
B+
C=
D()
Show Answer & Explanation

Correct Answer: C — =

Assignment operator has lower precedence than arithmetic operators.

Q21.

What will be the output?


int a = 5, b = 10;
printf("%d", a + b * 2);
A30
B25
C20
D15
Show Answer & Explanation

Correct Answer: B — 25

Multiplication has higher precedence than addition: 10*2 + 5 = 25.

Q22.

What will be the output?


printf("%d", (5 + 10) * 2);
A25
B30
C20
D15
Show Answer & Explanation

Correct Answer: B — 30

Parentheses have highest precedence.

Q23.
Which operator is used to test multiple conditions together?
A&
B&&
C|
D^
Show Answer & Explanation

Correct Answer: B — &&

&& is logical AND operator.

Q24.

What will be the output?


int x = 1;
printf("%d", x++ + ++x);
A3
B4
CUndefined
DCompilation error
Show Answer & Explanation

Correct Answer: C — Undefined

Modifying variable more than once between sequence points leads to undefined behavior.

Q25.

What will be the output?


printf("%d", 0 || 5);
A0
B1
C5
DError
Show Answer & Explanation

Correct Answer: B — 1

Logical OR returns 1 if any operand is true.

Q26.
Which operator is used to combine bits?
A&&
B|
C||
D!
Show Answer & Explanation

Correct Answer: B — |

Bitwise OR combines bits.

Q27.

What will be the output?


printf("%d", ~1);
A-1
B-2
C0
D1
Show Answer & Explanation

Correct Answer: B — -2

~1 inverts all bits; result depends on two's complement representation.

Q28.
Which operator is evaluated last?
A()
B*
C+
D=
Show Answer & Explanation

Correct Answer: D — =

Assignment operator has the lowest precedence.

Q29.

What will be the output?


int a = 10;
printf("%d", a += 5);
A10
B15
C5
DError
Show Answer & Explanation

Correct Answer: B — 15

a += 5 is equivalent to a = a + 5.

Q30.
Which of the following is NOT an assignment operator?
A+=
B*=
C/=
D==
Show Answer & Explanation

Correct Answer: D — ==

== is a relational operator, not assignment.

Q31.

What will be the output?


printf("%d", 5 << 1);
A5
B10
C2
D1
Show Answer & Explanation

Correct Answer: B — 10

Left shift by 1 multiplies by 2.

Q32.
Which operator is used for pointer dereferencing?
A&
B*
C->
D.
Show Answer & Explanation

Correct Answer: B — *

* dereferences a pointer.

Q33.

What will be the output?


int a = 0;
printf("%d", !a);
A0
B1
CTrue
DError
Show Answer & Explanation

Correct Answer: B — 1

Logical NOT of 0 is 1.

Q34.
Which operator checks inequality?
A=
B==
C!=
D<>
Show Answer & Explanation

Correct Answer: C — !=

!= checks not equal condition.

Q35.

What will be the output?


printf("%d", 4 & 1);
A0
B1
C4
D5
Show Answer & Explanation

Correct Answer: A — 0

4 (100) & 1 (001) = 000.

Q36.
Which operator is evaluated from right to left?
A+
B*
C=
D%
Show Answer & Explanation

Correct Answer: C — =

Assignment operator has right-to-left associativity.

Q37.

What will be the output?


printf("%d", 10 % 3);
A1
B3
C0
DError
Show Answer & Explanation

Correct Answer: A — 1

Modulus operator returns remainder.

Q38.
Which operator is used to separate expressions?
A;
B,
C:
D.
Show Answer & Explanation

Correct Answer: B — ,

Comma operator evaluates expressions left to right.

Q39.

What will be the output?


printf("%d", (5 > 3) + (2 > 4));
A0
B1
C2
DError
Show Answer & Explanation

Correct Answer: B — 1

True is 1 and false is 0 → 1 + 0 = 1.

Q40.
Which of the following is a unary operator?
A+
B*
C++
D&&
Show Answer & Explanation

Correct Answer: C — ++

++ operates on a single operand.