- Arithmetic operators and operator precedence
- Integer division and the modulus operator
- Assignment shortcuts like += and post-increment x++
- Relational (==, !=, <, >) and logical (&&, ||, !) operators
- Bitwise operations (&, |, ^, ~) and shift operators (<<, >>)
- sizeof operator and platform-dependent sizes
- Ternary operator ?: for simple conditions
This page has 30 multiple choice questions on operators in C. Each question includes the correct answer and a short explanation in plain English, so you understand the "why" and not just the "what". Questions are grouped by topic: arithmetic, assignment, relational, logical, bitwise, shift, sizeof, and ternary. These MCQs are useful for beginners preparing for college exams, interviews, or any C programming test. Read each explanation carefully — many of these questions test small details that trip up beginners in exams.
Arithmetic Operators & Precedence
Q1. What is the output of the expression 6 + 5 * 2?
Answer: b) 16
Multiplication has higher precedence than addition in C, so 5 * 2 is evaluated first and gives 10. Then 6 + 10 gives 16. If you wanted the addition to happen first, you would write (6 + 5) * 2, which would give 22.
Q2. What is the result of the expression 12 / 5?
Answer: a) 2
Both 12 and 5 are integers, so C performs integer division. The fractional part is thrown away, and the result is 2. To get 2.4, at least one operand must be a float, like 12.0 / 5. This is a very common trap in C exams.
Q3. What is the output of the expression 5 % 3?
Answer: b) 2
The % operator gives the remainder after division. 5 divided by 3 is 1, with a remainder of 2, so the answer is 2. The % operator only works with integers in C — you cannot use it with float or double.
Q4. What is the result of the expression (2 + 3) * 4?
Answer: a) 20
Parentheses have the highest precedence, so 2 + 3 is evaluated first and gives 5. Then 5 * 4 gives 20. Without the parentheses, 2 + 3 * 4 would give 14 because multiplication comes first.
Q5. What is the value of x after x = 10 / 3;?
Answer: a) 3
Both 10 and 3 are integers, so integer division is performed. The decimal part is dropped, and x becomes 3. To get 3.33, you would need to write 10.0 / 3 or use a float variable.
Q6. What is the value of x after x = 5 / 2;?
Answer: a) 2
Since both 5 and 2 are integers, integer division is used. The result is 2, because the .5 part is truncated. If you want 2.5, write 5.0 / 2 or 5 / 2.0.
Q7. What is the value of x after x = 5 % 2;?
Answer: c) 1
The % operator returns the remainder. 5 divided by 2 is 2 with a remainder of 1, so x becomes 1. This operator is very useful for checking even/odd numbers or wrapping values in a range.
Assignment & Increment Operators
Q8. What is the value of x after x += 5; if x is initially 10?
Answer: a) 15
The += operator is a shorthand for addition and assignment. x += 5 means x = x + 5. Since x was 10, it becomes 15. Similar shorthand operators exist for other operations too, like -=, *=, /=, and %=.
Q9. What is the value of x after x++ if x is initially 5?
Answer: a) 6
The post-increment operator x++ increases the value of x by 1. After the statement, x becomes 6. Note that if x++ were used inside another expression, the old value would be used first and then incremented — that's the difference between x++ and ++x.
Relational & Equality Operators
Q10. The expression 10 == 5 results in ________.
Answer: b) false
The == operator checks if two values are equal. Since 10 is not equal to 5, the result is false. In C, false is represented internally as 0. Don't confuse == (comparison) with = (assignment).
Q11. The result of the expression 10 != 5?
Answer: a) true
The != operator returns true if the two values are different. Since 10 is not equal to 5, the result is true, which is stored as 1 in C. This is the exact opposite of the == operator.
Logical Operators
Q12. The expression 5 > 3 && 2 < 4 after execution gives the result?
Answer: a) true
The logical AND operator && returns true only if both conditions are true. Here 5 > 3 is true and 2 < 4 is also true, so the whole expression is true. In C, true is represented by the value 1.
Q13. !(3 == 5) = _____?
Answer: a) true
First, 3 == 5 is evaluated. Since 3 is not equal to 5, it returns false (0). The logical NOT operator ! flips it, so !0 becomes 1 (true). So the whole expression evaluates to true.
Q14. What is the result of 5 && 0?
Answer: b) false
In C, any non-zero value is treated as true, and 0 is false. The expression 5 && 0 has one true operand and one false operand. Since && requires both to be true, the result is false (0).
Q15. What is the result of 10 && 5?
Answer: a) true
In C, any non-zero value counts as true. Both 10 and 5 are non-zero, so the logical AND gives true. The result is 1. This surprises many beginners who expect 10 && 5 to give 50 or 10 — it doesn't; it just gives 1.
Q16. The expression 10 || 0 results in _________.
Answer: a) true
The logical OR operator || returns true if at least one operand is true. Since 10 is non-zero (true), the whole expression is true, i.e., 1. OR is more lenient than AND — it needs only one true value.
Bitwise & Shift Operators
Q17. What is the result of the expression 5 << 2?
Answer: a) 20
The left shift operator << moves the bits of the left operand to the left. Shifting 5 (binary 101) left by 2 positions gives 10100 in binary, which is 20 in decimal. A quick rule: left shift by n multiplies the number by 2^n.
Q18. What is the result of the expression 10 >> 1?
Answer: a) 5
The right shift operator >> moves bits to the right. 10 in binary is 1010. Shifting right by 1 gives 101, which is 5. Right shift by n is roughly like dividing by 2^n for positive integers.
Q19. What is the result of the expression 10 | 6?
Answer: d) 14
The bitwise OR operator | compares each bit and returns 1 if either bit is 1. 10 in binary is 1010, and 6 is 0110. ORing them gives 1110, which is 14 in decimal.
Q20. What is the result of the expression 10 ^ 6?
Answer: d) 12
The bitwise XOR operator ^ returns 1 only if the bits differ. 10 is 1010 and 6 is 0110. XORing them gives 1100, which is 12 in decimal. XOR is useful for toggling bits.
Q21. What is the output of the expression ~5?
Answer: d) -6
The bitwise NOT operator ~ flips every bit. In two's complement (which C uses for signed integers), ~5 equals -6. A quick shortcut: ~x equals -(x + 1). So ~5 = -(5 + 1) = -6.
sizeof Operator
Q22. What is the result of the expression sizeof(int)?
Answer: d) Depends on the platform
The sizeof operator returns the size of a type in bytes. The C standard only guarantees a minimum size for int. On 16-bit systems int is 2 bytes, while on most modern 32-bit and 64-bit systems it is 4 bytes. That is why the answer depends on the platform.
Q23. What is the result of the expression sizeof('a')?
Answer: a) 1
In C, a character constant like 'a' has type char, and sizeof(char) is always 1 byte by definition. Note that this is one type whose size never changes across platforms.
Q24. What is the result of the expression sizeof(float)?
Answer: a) 4
On almost all modern compilers, float is 4 bytes. The C standard does not strictly fix it, but 4 bytes is the norm everywhere, including Windows, Linux, and macOS.
Q25. What is the result of the expression sizeof(double)?
Answer: b) 8
A double is 8 bytes on almost all modern compilers. It gives more precision than float. The C standard does not strictly fix it, but 8 bytes is the standard answer in exams.
Q26. What is the result of the expression sizeof(char)?
Answer: a) 1
By definition, sizeof(char) is always 1 byte in C. This is the only type whose size is fixed by the standard. All other type sizes can vary between platforms.
Q27. What is the result of the expression sizeof(long)?
Answer: d) Depends on the platform
The size of long varies. On 32-bit Windows it is 4 bytes, but on 64-bit Linux and macOS it is 8 bytes. The C standard only guarantees that long is at least 4 bytes, so the correct answer is that it depends on the platform.
Q28. What is the result of the expression sizeof(short)?
Answer: c) 2
A short is 2 bytes on almost all compilers. The C standard guarantees that short is at least 2 bytes, and in practice it is always 2 bytes on modern systems.
Q29. What is the result of the expression sizeof(unsigned int)?
Answer: a) 4
An unsigned int has the same size as a signed int. On most modern compilers it is 4 bytes. The unsigned keyword only changes the range (0 to 4 billion instead of -2 billion to +2 billion), not the size.
Ternary & Miscellaneous Operators
Q30. What is the result of the expression 5 > 3 ? 10 : 20?
Answer: b) 10
The ternary operator ?: works like a short if-else. The condition 5 > 3 is true, so it returns the value before the colon, which is 10. If the condition were false, it would return 20 instead. This is a compact way to write simple if-else statements.
Frequently Asked Questions
Which operator has the highest precedence in C?
Parentheses () have the highest precedence. After that come postfix operators like ++ and --, then unary operators, then multiplicative operators (*, /, %), and so on down the precedence table. When in doubt, use parentheses to make your intent clear.
What is the difference between = and == in C?
The = operator assigns a value to a variable. The == operator compares two values. For example, x = 5 stores 5 in x, whereas x == 5 checks whether x equals 5 and returns 1 (true) or 0 (false). Mixing them up is one of the most common beginner mistakes in C.
Why does sizeof(int) depend on the platform?
The C standard does not fix the size of int. It only guarantees a minimum size. On 16-bit systems int is 2 bytes, while on 32-bit and 64-bit systems it is usually 4 bytes. This is why portable code often uses types like int32_t from stdint.h when the exact size matters.
What does the modulus operator % do in C?
The % operator returns the remainder after division. For example, 5 % 2 gives 1 because 5 divided by 2 leaves a remainder of 1. It works only with integers in C — you cannot use % with float or double.
Why does 12 / 5 give 2 and not 2.4 in C?
When both operands are integers, C performs integer division and discards the fractional part. To get 2.4, at least one operand must be a float, like 12.0 / 5. This is different from languages like Python 3, where 12 / 5 automatically gives 2.4.
💡 Tip: Try answering all 30 questions before checking the answers. This helps you spot which operator category needs more practice. Pay special attention to integer division and sizeof — those two catch most beginners in exams.