By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

explain the output of this program

P: 6
#include<iostream.h>
void main()
{int x=1,y=1;
for(;y;cout<<x<<'\t'<<y<<endl)
y=x++<=5;
}

output is
2 1
3 1
4 1
5 1
6 1
7 0
Aug 10 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
#include<iostream.h>
Expand|Select|Wrap|Line Numbers
  1. void main()
  2. {int x=1,y=1;
  3. for(;y;cout<<x<<'\t'<<y<<endl)
  4. y=x++<=5;
  5. }
  6.  
output is
2 1
3 1
4 1
5 1
6 1
7 0
Please add [ code ] ... [ /code ] tags around your source text (without the spaces).
And also please make that 'int main()' instead of 'void main()' and again please,
why don't you try to trace the execution using pencil and paper yourself? It isn't
that difficult.

kind regards,

Jos
Aug 10 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.