C- Bitwise Operators Questions and Answers
Practice ModeShowing 10 of 24 questions
Q11
What is the value of 1 << 3?
Answer: Option D
Explanation: Left shift 1 by 3 positions: 1 * 2^3 = 8
Q12
Which operator is used to check if a particular bit is set?
Answer: Option B
Explanation: AND operator with mask checks specific bit
Q13
What is the output of: printf("%d", 15 ^ 7);
Answer: Option A
Explanation: XOR operation: 15 (1111) XOR 7 (0111) = 8 (1000)
Q14
How to set a particular bit in C?
Answer: Option B
Explanation: OR operation with mask sets specific bit
Q15
What is the result of 16 >> 2?
Answer: Option C
Explanation: Right shift by 2 divides by 4: 16/4 = 4
Q16
Which operator has highest precedence among bitwise operators?
Answer: Option D
Explanation: Bitwise NOT has highest precedence
Q17
What is the output of: printf("%d", ~5);
Answer: Option B
Explanation: Assuming 32-bit: 5=00000101, ~5=11111010 (2s complement = -6)
Q18
How to clear a specific bit in C?
Answer: Option B
Explanation: AND with complement of mask clears bit
Q19
What is the value of 12 & 10?
Answer: Option C
Explanation: 12 (1100) AND 10 (1010) = 8 (1000)
Q20
What does the expression (x >> n) do?
Answer: Option B
Explanation: Right shift divides by 2^n