C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Find Output of Program (Q.No. 7)
7.
What is the output of the program
#include<stdio.h>
int main()
{
    int x = 10, y = 20, z = 5, i;
    i = x < y < z;
    printf("%d\n", i);
    return 0;
}
0
1
Error
None of these
Answer: Option
Explanation:
Since x < y turns to be TRUE it is replaced by 1. Then 1 < z is compared and to be TRUE. The 1 is assigned to i.
Discussion:
37 comments Page 4 of 4.

Chelladurai said:   1 decade ago
Ya it is really good explanation.

Rohan said:   8 years ago
What if it is from right to left?
(1)

Bis said:   1 decade ago
What is the use of this code?
(1)

Jayanth said:   2 decades ago
Is it correct explaination?

Krishna said:   1 decade ago
Why it is 10 not 20 or 30?

Sneha said:   1 decade ago
Explain me before program.

Sugu said:   1 decade ago
How is it possible?


Post your comments here:

Your comments will be displayed after verification.