1. What will be the output of the program? #include<stdio.h> int main() { int x=55; printf("%d, %d, %d\n", x<=55, x=40, x>=10); return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.01 pm
Step 1: int x=55; here variable x is declared as an integer type and initialized to '55'. Step 2: printf("%d, %d, %d\n", x<=55, x=40, x>=10); In printf the execution of expressions is from Right to Left. here x>=10 returns TRUE hence it prints '1'. x=40 here x is assigned to 40 Hence it prints '40'. x<=55 returns TRUE. hence it prints '1'. Step 3: Hence the output is "1, 40, 1".
Step 2: printf("%d, %d, %d\n", x<=55, x=40, x>=10);
In printf the execution of expressions is from Right to Left.
here x>=10 returns TRUE hence it prints '1'.
x=40 here x is assigned to 40 Hence it prints '40'.
x<=55 returns TRUE. hence it prints '1'.
Step 3: Hence the output is "1, 40, 1".