C | Operators | Question 26
#include <stdio.h> int main() { int y = 0; int x = (~y == 1); printf ( "%d" , x); return 0; } |
(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
Please Login to comment...