C- Bitwise Operators Questions and Answers

Practice Mode
Showing 10 of 24 questions
Q11
What is the value of 1 << 3?
  • A 1
  • B 3
  • C 6
  • D 8
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?
  • A OR operator
  • B AND operator
  • C XOR operator
  • D NOT operator
Answer: Option B
Explanation: AND operator with mask checks specific bit
Q13
What is the output of: printf("%d", 15 ^ 7);
  • A 8
  • B 15
  • C 7
  • D 22
Answer: Option A
Explanation: XOR operation: 15 (1111) XOR 7 (0111) = 8 (1000)
Q14
How to set a particular bit in C?
  • A AND with mask
  • B OR with mask
  • C XOR with mask
  • D NOT with mask
Answer: Option B
Explanation: OR operation with mask sets specific bit
Q15
What is the result of 16 >> 2?
  • A 16
  • B 8
  • C 4
  • D 2
Answer: Option C
Explanation: Right shift by 2 divides by 4: 16/4 = 4
Q16
Which operator has highest precedence among bitwise operators?
  • A AND (&)
  • B OR (|)
  • C XOR (^)
  • D NOT (~)
Answer: Option D
Explanation: Bitwise NOT has highest precedence
Q17
What is the output of: printf("%d", ~5);
  • A 5
  • B -6
  • C 6
  • 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?
  • A OR with mask
  • B AND with complement of mask
  • C XOR with mask
  • D NOT with mask
Answer: Option B
Explanation: AND with complement of mask clears bit
Q19
What is the value of 12 & 10?
  • A 12
  • B 10
  • C 8
  • D 14
Answer: Option C
Explanation: 12 (1100) AND 10 (1010) = 8 (1000)
Q20
What does the expression (x >> n) do?
  • A Multiplies x by 2^n
  • B Divides x by 2^n
  • C Adds n to x
  • D Subtracts n from x
Answer: Option B
Explanation: Right shift divides by 2^n
Questions and Answers for Competitive Exams Various Entrance Test