First time here? Checkout the FAQ!
x
menu search
brightness_auto
more_vert

What will be the output of the following C code?  please explain this code 


#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x == 0)
printf("inside if\n");
else
printf("inside else if\n");
else
printf("inside else\n");
}

thumb_up_off_alt 1 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
Best answer

OUPUT WILL  be 


 inside else 





explaination 

x is declared as 0 in intitialiazation
 and 

the first if condition says if x=1 then only execute inside this loop 

but x=0 therefore it skips the loop

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
...