Home » C Programming » Operators » Question
  1. 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;
    }
    1. z = 100
    2. z = 200
    3. z = 1
    4. z = 0
    5. 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).



Your comments will be displayed only after manual approval.