FOR Loop statement

My FOR loop statement doesn't work with any 4digit number, it works with 100 but not 1000 which is what I need it to count down from, I don't understand why it'll work with 100 but not 1000, it counts down from 596 for some reason, here is my code:


int meow;
for(meow= 1001; meow > -1; meow--)
{
meow--;
cout << meow << endl;

if (meow == 0)
cout << "Blast off!";
}
Last edited on
Drop this line: meow--; You are already post decrementing meow in your for loop. It isn't counting down at 596, I assume you're scrolling up on the console window and that's the first you number you see.
Yeah I want it going in decrements of 2, that is the first number I see, why can't I see 1000?
Last edited on
The count down is starting at 1001. There is a limitation to how many rows the console window will display.
So a console window will only display 597/598 rows?
Cheers mate just managed to spot at least 700 before it got wiped off the screen.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int j =0;
int meow;
for(meow= 1001; meow > -1; meow-=2)
{
cout << meow << "  ";
if (j==4) {cout << endl; j=0;}
j++;


if (meow == 0)
cout << "Blast off!";
}



try this,
Last edited on
1
2
for (int j=0;j<5;j++)
{if (j==4) {cout << endl;}}


huh??
Intended to prints meow 5 times on each line. Sorry, didnt get a moment of sleep last night. It should be fixed now.
Topic archived. No new replies allowed.