Discussion :: Control Instructions
-
What will be the output of the program?
#include
Answer : Option A
Explanation :
Step 1: char str[]="C-program"; here variable str contains "C-program".
Step 2: int a = 5; here variable a contains "5".
Step 3: printf(a >10?"Ps\n":"%s\n", str); this statement can be written as
if(a > 10) { printf("Ps\n"); } else { printf("%s\n", str); }
Here we are checking a > 10 means 5 > 10. Hence this condition will be failed. So it prints variable str.
Hence the output is "C-program".
Be The First To Comment