Meenu wrote:[color=blue]
> The output of the following program confuses me
>
> void main()[/color]
This is wrong. Use
int main(void)
[color=blue]
> {
> int x=10,y=20,z=5,i ;
> i=x<y<z;
> printf("i=%d\n" ,i);
> }[/color]
i=x<y<z is equivalent to
i = ((x<y)<z); <--- x<y is True
i = ( 1 < z) <--- 1<y is True.
i = 1
Maw wrote:[color=blue]
>
> y<z is 0
> x<0 is 1
> i=x[/color]
That's nice. On what do you base that assertion? See below.
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
You are missing needed headers, since printf is a variadic function.
#include <stdio.h>
The 'void' return type for main() in [1] is wrong. main returns an int.
In [2], your main does return an int implicitly in C89 (or C90), where a
function that has no named returned type is assumed to return an int.
However, (a) implicit int is removed from the current standard, so [2]
is wrong under the current standard. Further, in C89 (and C90) in which
implicit int is allowed, main() should explicitly return a value.
In [2], there is no way to predict the output. To have a portable C
program, the last line of output to a stream must end in an end-of-line
('\n') character.
Now tell me that you're a troll and that I took the bait.
"Maw" <martinaw@gmail .com> writes:[color=blue]
> *the other way*[/color]
You've posted twice on this thread without providing any context or
attributions. I have no idea what you mean by "the other way".
The broken groups.google.c om interface is partly responsible for this,
but only partly. It *is* possible to use groups.google.c om properly.
The following has been posted here hundreds of times. Read it. Pay
attention to it.
If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
--
Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Comment