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 3 of 4.

Trisha said:   1 decade ago
What is the priority of =, < and > symbols. Can anyone explain?

Mary said:   1 decade ago
Can you explain what is the result if the case is like x>y>z?

Xyz said:   1 decade ago
Thanks wikiok your explanation helped me to understand the answer.

Rishi said:   9 years ago
Y>z = 20>5 true 1 then 1>10.

False 0.

1 true 1 false.

Agnes said:   8 years ago
10<20=false ===>0
0<5=true===>1

Hence the output 1.
(1)

Shine said:   1 decade ago
can anyone tell me the priorities of < , > ,= operators?

Swetha said:   1 decade ago
Can you explain in depth? why it is replacing with 1?

Shivaji said:   1 decade ago
i=x,y,z;
Because it is
Just like below..
i=x;
y;
z;

Kanniyappan said:   9 years ago
Is it possible to compare flag value < 5?

Ssindham said:   9 years ago
Your Explanation is perfect @Wikiok.


Post your comments here:

Your comments will be displayed after verification.