Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

C | Operators | Question 27

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Output of following C code will be?


#include <stdio.h>
int main()
   int a = 0;
   int b;
   a = (a == (a == 1));
   printf("%d", a);
   return 0;






Big negative number



Answer: (B)


We need to figure out value of “(a == (a == 1))” 

(a == 1) returns false as a is initialized as 0. So in outer bracket, false is compared with a. Since a is 0, result of of outer bracket becomes true. 

The important thing to note is, in C, when a boolean value is compared or assigned to an integer value, false is considered as 0 and true is considered as 1.

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads