Last Updated : 14 Feb, 2019

What will be the output of the following program?

#include <stdio.h> 
#include <stdbool.h> 

int main() 
{ 
    int a=10, b=10; 

    bool res = ((a != b) || ((a == b) || printf(\"GeeksForGeeks\"))); 

    return 0; 
} 

(A) GeeksForGeeks
(B) False
(C) No Output
(D) Error


Answer: (C)

Explanation: In the statement, bool res = ((a != b) || ((a == b) || printf(\”GeeksForGeeks\”)));
since (a != b) results in false, ((a == b) || printf(\”GeeksForGeeks\”)) will be evaluated then.
In this, since (a==b) results true, therefore evaluation stops and true is assigned to res.
The printf(\”GeeksForGeeks\”) statement is not executed.

Quiz of this Question


Share your thoughts in the comments