Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 What will be the output of the program? #include<stdio.h> int main() { char str[]="C-program"; int a = 5; printf(a >10?"Ps\n":"%s\n", str); return 0; } ?->(Show Answer!)
1. What will be the output of the program? #include<stdio.h> int main() { char str[]="C-program"; int a = 5; printf(a >10?"Ps\n":"%s\n", str); return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.01 pm
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".
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".