-
Which of the following is the correct output for the program given below ?
#include <stdio.h>
int main ( )
{
int x = 10, y = 20, z;
z = (x == 10 || y > 20);
printf ( "z = %d\n", z);
return 0;
}
-
- z = 100
- z = 200
- z = 1
- z = 0
- z = 300
Correct Option: C
Step 1: int x=10, y=200, z;
Step 2: z = (x == 10 || y > 20);
becomes z = (10 == 10 || 20 > 20);
becomes z = (TRUE || FALSE);
becomes z = (TRUE); (ie. z = 1)
Step 3: printf("z=%d\n", z); It prints the value of variable z=1
Hence the output of the program is '1'(one).