Skip to content
Related Articles

Related Articles

Improve Article

C | Operators | Question 26

  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021

#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

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :