Joined: Wed Oct 27, 2010 11:20 pm Posts: 2 Has thanked: 0 time Have thanks: 1 time
to write a for loop first identify a variable like int i; then for(i=0;i<25;i++)//i starting from 0 to <25 means to 24//i++means it is ascending { cout<<i<<endl; } that code will cout from 0 up to 24 if u want the code descending for(i=25;i>0;i--) { cout<<i<<endl; }
For this message the author alaa111151 has received gratitude : msi_333
shoaib49
Code subject: Re: C ++ problems
Posted: Tue Jan 17, 2012 7:54 am
mestz6 wrote:
Trying to figure out how to write this program. Its a ..for loop and I never have written one. The loop is suppose to produce some kind of output.
x = 0 cout = 1; while (cout <=25) { x = x-count; count ++; }
See brother u have declared x as 0 therefore looping condition is x=x-count i.e 0=0-(count). but for seeing this result u must write a printf statement i.e printf("X= %d",x); OK ! If any problem u have contact me at (shoaib_sayyed49@yahoo.com) I would love to help my brothers.