Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   comparsion (http://www.go4expert.com/forums/comparsion-t8334/)

answerme 19Jan2008 10:30

comparsion
 
main()
{
int x=10 ,y=20,z=5 ,i;
i=x<y<z;
printf("%d",i);
}

output :1
why the output is 1 ,how x ,y ,z are gettting compared

shabbir 19Jan2008 10:52

Re: comparsion
 
Just put a brackets and see how its getting evaluated.

Check the output for both the cases below
i=(x<y)<z;
i=x<(y<z);

asadullah.ansari 21Jan2008 10:58

Re: comparsion
 
i=x<y<z
=> i= 10<20<z
=> i= true(1) < 5
=> i= true(1)
=> i=1
This is true If Compiler evaluates from Left to Right if same perority operator are there.


All times are GMT +5.5. The time now is 13:47.