MCQs on Operators and Expressions | C Programming

Understanding Operators and Expressions in C Programming
In Chapter 3, we explore operators and expressions, which form the backbone of logical and mathematical operations in C programming. Key topics include arithmetic operators such as +, -, *, /, and %, which perform basic calculations. Relational operators (==, !=, >, <, >=, <=) allow for value comparisons, while logical operators (&&, ||, !) help create complex conditions. Bitwise operators like &, |, and ^ work on binary values for bit manipulation. This chapter also covers assignment operators (+=, -=, etc.), increment/decrement operators (++, --), and expression precedence, ensuring a solid foundation in C’s operational capabilities.

Chapter 3: Operators and Expressions

Arithmetic Operators

  1. What does the operator % do in C?
    • a) Multiplies two numbers
    • b) Divides two numbers
    • c) Gives the remainder of division
    • d) Adds two numbers
  2. What will the output of 10 / 3 be in C?
    • a) 3.33
    • b) 3
    • c) 4
    • d) 3.0
  3. What is the result of 5 * 3 + 4?
    • a) 15
    • b) 17
    • c) 19
    • d) 9
  4. What is the output of 20 - 5 * 2?
    • a) 10
    • b) 30
    • c) 15
    • d) 5
  5. What is the result of 9 % 2 in C?
    • a) 0
    • b) 2
    • c) 1
    • d) 4.5

Relational Operators

  1. Which operator is used to check if two values are equal?
    • a) =
    • b) ==
    • c) !==
    • d) <=
  2. What does the expression 5 > 3 return?
    • a) 5
    • b) 3
    • c) 1
    • d) 0
  3. What is the output of 6 >= 6?
    • a) true
    • b) 1
    • c) false
    • d) 0
  4. Which of these will return true if a = 3 and b = 4?
    • a) a > b
    • b) a < b
    • c) a >= b
    • d) a == b
  5. What will 7 != 5 evaluate to?
    • a) 0
    • b) 1
    • c) false
    • d) None of these

Logical Operators

  1. Which of the following is a logical operator?
    • a) &
    • b) &&
    • c) %
    • d) |=
  2. What is the result of 1 && 0?
    • a) 0
    • b) 1
    • c) true
    • d) false
  3. What will !0 evaluate to?
    • a) 0
    • b) 1
    • c) null
    • d) error
  4. If a = 5 and b = 0, what does (a || b) return?
    • a) 5
    • b) 1
    • c) 0
    • d) false
  5. Which expression is true if x = 1 and y = 0?
    • a) x && y
    • b) x || y
    • c) !x
    • d) y && x

Bitwise Operators

  1. What does the operator & do in bitwise operations?
    • a) OR operation
    • b) AND operation
    • c) NOT operation
    • d) XOR operation
  2. What is the result of 5 & 3 in binary?
    • a) 101
    • b) 1
    • c) 111
    • d) 0
  3. Which bitwise operator is used for negation?
    • a) ~
    • b) &
    • c) ^
    • d) |
  4. What is the result of 4 | 1?
    • a) 0
    • b) 5
    • c) 4
    • d) 1
  5. Which of the following shifts bits to the left?
    • a) <<
    • b) >>
    • c) &
    • d) |

Assignment Operators

  1. What does a += 2 mean?
    • a) a = a + 2
    • b) a = 2
    • c) a + 2
    • d) Increment by 2
  2. If a = 3, what is the value of a *= 4?
    • a) 3
    • b) 12
    • c) 1
    • d) 7
  3. What is the shorthand for b = b - 5?
    • a) b+5
    • b) b=-5
    • c) b-=5
    • d) b=-+5
  4. What is the output of a = 5; a /= 2;?
    • a) 2.5
    • b) 2
    • c) 5
    • d) 0
  5. Which of the following is not an assignment operator?
    • a) +=
    • b) /=
    • c) *=
    • d) =+

Increment and Decrement Operators

  1. What is the result of int a = 5; a++;?
    • a) 5
    • b) 6
    • c) 7
    • d) 4
  2. If x = 4, what does ++x mean?
    • a) x = x + 1
    • b) x = x - 1
    • c) x = 1
    • d) x = x
  3. What is the difference between x++ and ++x?
    • a) No difference
    • b) x++ increments after, ++x increments before
    • c) ++x increments after, x++ increments before
    • d) They both decrement
  4. What is the output of int a = 7; a--;?
    • a) 6
    • b) 7
    • c) 5
    • d) 8
  5. If y = 10, what does --y result in?
    • a) 9
    • b) 10
    • c) 11
    • d) 0

Expressions and Precedence

  1. What is operator precedence?
    • a) Order of operations
    • b) Priority of operator evaluation
    • c) Order of code lines
    • d) Importance of variables
  2. What has higher precedence, * or +?
    • a) +
    • b) *
    • c) Same precedence
    • d) No precedence
  3. Which operator has the lowest precedence?
    • a) &&
    • b) ||
    • c) ==
    • d) +
  4. What is the result of 5 + 2 * 3?
    • a) 21
    • b) 11
    • c) 9
    • d) 15
  5. What is the output of 4 * 2 + 3?
    • a) 14
    • b) 11
    • c) 10
    • d) 7

Arithmetic Operators (Continued)

  1. What is the value of 7 % 4?
  • a) 3
  • b) 4
  • c) 1
  • d) 0
  1. If a = 10 and b = 20, what is the result of a * b + a / b?
  • a) 10
  • b) 20
  • c) 200.5
  • d) 200

Relational Operators (Continued)

  1. Which operator would you use to check if x is not equal to y?
  • a) =
  • b) !=
  • c) <>
  • d) ^
  1. If x = 10 and y = 5, what is the result of (x > y) && (x < 15)?
  • a) 1
  • b) 0
  • c) True
  • d) False
  1. Which of the following is not a relational operator?
  • a) ==
  • b) &&
  • c) !=
  • d) <

Logical Operators (Continued)

  1. Which logical operator is used to combine multiple conditions to check if both are true?
  • a) ||
  • b) &&
  • c) !
  • d) &=
  1. In C, what does the expression (5 > 3) || (2 < 1) return?
  • a) true
  • b) 0
  • c) 1
  • d) false
  1. What does !(5 == 5) evaluate to?
  • a) 5
  • b) 0
  • c) 1
  • d) -1
  1. If a = 1 and b = 0, what is the result of !(a && b)?
  • a) 1
  • b) 0
  • c) true
  • d) false

Bitwise Operators (Continued)

  1. Which operator is used for the bitwise XOR operation?
  • a) |
  • b) &
  • c) ^
  • d) ~
  1. What is the result of 5 | 3 in binary?
  • a) 101
  • b) 111
  • c) 100
  • d) 110
  1. If x = 4, what is the result of x << 1?
  • a) 2
  • b) 8
  • c) 1
  • d) 4
  1. Which operator shifts bits to the right?
  • a) <<
  • b) >>
  • c) ||
  • d) ==

Assignment Operators (Continued)

  1. If x = 8, what does x -= 3 do?
  • a) Sets x to 3
  • b) Sets x to 5
  • c) Sets x to 8
  • d) Sets x to 11
  1. If y = 10, what is the result of y %= 3?
  • a) 3
  • b) 1
  • c) 0
  • d) 7

Answer Key

Q1Q2Q3Q4Q5Q6Q7Q8Q9Q10
cbbacbcbbb
Q11Q12Q13Q14Q15Q16Q17Q18Q19Q20
babbbbbaba
Q21Q22Q23Q24Q25Q26Q27Q28Q29Q30
abcbdbabaa
Q31Q32Q33Q34Q35Q36Q37Q38Q39Q40
bbbbbadbab
Q41Q42Q43Q44Q45Q46Q47Q48Q49Q50
bcbacbbbbb

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top