Sail E0 Webinar
Question


What will be the output of the program?


#include<stdio.h>
int main()
{
int a=100, b=200, c;
c = (a == 100 || b > 200);
printf("c=%d\n", c);
return 0;
}
Options:
A .  c=100
B .  c=200
C .  c=1
D .  c=300
Answer: Option C

Step 1: int a=100, b=200, c;
Step 2: c = (a == 100 || b > 200);
becomes c = (100 == 100 || 200 > 200);
becomes c = (TRUE || FALSE);
becomes c = (TRUE);(ie. c = 1)
Step 3: printf("c=%d`setminus`n", c); It prints the value of variable i=1
Hence the output of the program is '1'(one).




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers