The result of this code is 65535 But I believe that for && both sides must hold true (rather one side being true is enough for ||) so how come the result is 65535 ????? when after 5++ the first condition becomes false ????? Thanks in advance

#include<stdio.h>
#include<conio.h>

void main()
{
 short int i=0;
 clrscr();

 for(i<=5&&i>=-1;++i;i>0)
 printf("%u",i);
 getch();
}

The for loop is completely nonsensical. It's like this:

for (initialization; condition; increment)
{
    body
}

Where the roughly analogous while loop is:

initialization

while (condition)
{
    body
    increment
}

So your loop, for(i<=5&&i>=-1;++i;i>0) printf("%u",i); would look something like this while loop:

i <= 5 && i >= 1;

while (++i)
{
    printf("%u", i);
    i > 0;
}

Doesn't make much sense, does it?

Thanks deceptikon got it now......... the && is just initialization.
:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.