C | Operators | Question 27
#include <stdio.h> int main() { int a = 0; int b; a = (a == (a == 1)); printf("%d", a); return 0; } |
chevron_right
filter_none
(A) 0
(B) 1
(C) Big negative number
(D) -1
Answer: (B)
Explanation: 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
Recommended Posts:
- Operators in C | Set 2 (Relational and Logical Operators)
- C | Operators | Question 5
- C | Operators | Question 4
- C | Operators | Question 27
- C | Operators | Question 26
- C | Operators | Question 10
- C | Operators | Question 1
- C | Operators | Question 15
- C | Operators | Question 3
- C | Operators | Question 17
- C | Operators | Question 13
- C | Operators | Question 12
- C | Operators | Question 26
- C | Operators | Question 11
- C | Operators | Question 21
Improved By : nidhi_biet

