C | Operators | Question 26
#include <stdio.h> int main() { int y = 0; int x = (~y == 1); printf("%d", x); return 0; } |
chevron_right
filter_none
(A) 0
(B) 1
(C) A bog negative Number
(D) Compiler Error
Answer: (A)
Explanation: The important thing to note here is ~ is a bitwise not operator. So the value of ~0 would be all 1s in binary representation which means decimal value of ~0 is not 1. Therefore the result of comparison operator becomes 0.
Quiz of this Question
Recommended Posts:
- Operators in C | Set 2 (Relational and Logical Operators)
- C | Operators | Question 27
- C | Operators | Question 26
- C | Operators | Question 18
- C | Operators | Question 17
- C | Operators | Question 15
- C | Operators | Question 13
- C | Operators | Question 21
- C | Operators | Question 22
- C | Operators | Question 27
- C | Operators | Question 27
- C | Operators | Question 11
- C | Operators | Question 24
- C | Operators | Question 23
- C | Operators | Question 12



