Multiple Choice questions on Operators in C language,Arithmetic,logical,relational,conditional and shift operators

Q5.What is the value of x after the statement x += 5; if x is initially 10?
a) 15
b) 10
c) 5
d) 50
Answer: a) 15
Explanation:
The += operator adds the value from the right side of the variable to the left side and returns the result to the variable.


Q6.What is the value of x after the statement x++ if x is initially 5?
a) 6
b) 5
c) 4
d) 7
Answer: a) 6
Explanation: The post-increment operator x++ increments the current value of x after it is used in an expression.


Q7.What is the result of the expression sizeof(int)?
a) 4
b) 2
c) 8
d) Depends on the platform
Answer: d) Depends on the platform
Explanation: The sizeof operator returns the size of the data type in bytes, which may vary depending on the compiler and platform.


Q8.The expression 5>3 && 2<4 after execution gives the result?
a) true
b) false
c) 1
d) 0
Answer: a) true
Explanation: The logical && operator returns true if both conditions are true.


Q9. !(3==5) =_____?
a) true
b) false
c) 1
d) 0
Answer: a) true
Explanation: The logical NOT operator (!) negates the result of the expression inside it.


Q10. What is the result of the expression sizeof('a')?
a) 1
b) 2
c) 4
d) Depends on the platform
Answer: a) 1
Explanation:
The sizeof operator returns the size of the data type, not the value. The character constant "a" is of char type and is typically 1 byte in size.


Q11.What is the result of the expression 5<<2?
a) 20
b) 10
c) 40
d) 8
Answer: a) 20
Explanation:
The left shift << operator moves bits of the left operand to the left by the number of positions indicated by the right operand.


Q12.What is the result of the expression 10 >> 1?
a) 5
b) 10
c) 20
d) 1
Answer: a) 5
Explanation:
The right shift operator >> shifts the bits of the left operand to the right by the number of positions specified by the right operand.


Q13.What is the result of the expression sizeof(float)?
a) 4
b) 8
c) 2
d) Depends on the platform
Answer: a) 4
Explanation:
The sizeof operator returns the size of the data type in bytes, which is 4 bytes for a float on most platforms.


Q14.What is the result of the expression 10 | 6?
a) 4
b) 10
c) 6
d) 14
Answer: d) 14
Explanation:
Bitwise OR operator (|) performs bitwise OR operation on the corresponding bits of the operands.


Q15.What is the result of the expression 10 ^ 6?
a) 4
b) 10
c) 6
d) 14
Answer: d) 12
Explanation: The bitwise XOR operator ^ performs a bitwise XOR operation on corresponding bits of the operands.


Q16.What is the output of the expression ~5?
a) 5
b) -5
c) 10
d) -10
Answer: b) -6
Explanation: The bitwise NOT operator ~ flips all the bits of the operand, resulting in the two's complement of the operand.


Q17.What is the result of the expression sizeof(double)?
a) 4
b) 8
c) 16
d) Depends on the platform
Answer: b) 8
Explanation:
The sizeof operator returns the size of the data type in bytes, which is 8 bytes for a double on most platforms.

Q18.What is the value of x after the statement x = 10 / 3;?
a) 3
b) 3.33
c) 3.0
d) 4
Answer: C) 3.0
Explanation: In integer division, the result is also an integer. So, 10 / 3 results 3.


Q19.What is the result of the expression 5 && 0?
a) true
b) false
c) 1
d) 0
Answer: b) false
Explanation: The logical AND operator (&&) returns false if any of the operands are false.


Q20.What is the value of x after the statement x = 5 % 2;?
a) 2
b) 2.5
c) 1
d) 0.5
Answer: c) 1
Explanation: The modulus operator % returns the remainder of the division. So, 5%2 gives 1.

Q21.The expression 10==5 results in ________.
a) true
b) false
c) 1
d) 0
Answer: b) false
Explanation: The equality operator == returns true if the operands are equal, otherwise false.


Q22.What is the result of the expression 10&&5 ?
a) true
b) false
c) 1
d) 0 Answer: a) true
Explanation: The logical AND operator (&&) returns true if both operands are true.


Q23.The expression 10 || 0 results in _________.
a) true
b) false
c) 1
d) 0
Answer: a) true
Explanation: The logical OR operator || returns true if any of the operands are true.


Q24.What is the result of the expression sizeof(char)?
a) 1
b) 2
c) 4
d) Depends on the platform
Answer: a) 1
Explanation:
The sizeof operator returns the size of the data type in bytes, which is 1 byte for char on most platforms.


Q25.What is the result of the expression sizeof(long)?
a) 4
b) 8
c) 2
d) Depends on the platform
Answer: d) Depends on the platform
Explanation:
The sizeof operator returns the size of the data type in bytes, which may vary depending on the platform and compiler.


Q26.What is the result of the expression sizeof(short)?
a) 4
b) 8
c) 2
d) Depends on the platform
Answer: c) 2
Explanation:
The sizeof operator returns the size of the data type in bytes, which is 2 bytes on most platforms.


Q27.What is the result of the expression sizeof(unsigned int)?
a) 4
b) 8
c) 2
d) Depends on the platform
Answer: a) 4
Explanation:
The sizeof operator returns the size of the data type in bytes, which is typically 4 bytes for an unassigned int on most platforms.


Q28.What is the value of x after the statement x = 5 / 2;?
a) 2
b) 2.5
c) 2.0
d) 3
Answer: c) 2.0
Explanation: In integer division, the result is also an integer. So, 5 / 2 results to 2.


Q29.The Result of the Expression 10!=5?
a) true
b) false
c) 1
d) 0
Answer: a) true
Explanation:
The inequality operator (!=) returns true if the operands are not equal and false otherwise.


Q30.The expression 10 || 0 results in _________.
a) true
b) false
c) 1
d) 0
Answer: a) true
Explanation: The logical OR operator || returns true if any of the operands are true.


Previous Topic:-->>Intro to C MCQ. || Next topic:-->>Conditional Statement MCQ.