Skip to content
Related Articles
Open in App
Not now

Related Articles

C | Operators | Question 26

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article




#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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!