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: (A)

Explanation: In the statement, bool res = ((a != b) && printf(\”GeeksForGeeks\”));
Since (a != b) results in true, therefore the printf(\”GeeksForGeeks\”) statement will be then executed, resulting in integer value 13 which is equivalent to true in boolean.
Therefore res is assigned true.

Quiz of this Question


  • Last Updated : 14 Feb, 2019

Share your thoughts in the comments