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=4; 

    bool res = ((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) || printf(\”GeeksForGeeks\”));
since (a != b) results in 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