For Loop not continuing

Oct 22, 2009 at 2:01pm
I'm writing a code that counts numbers using a for loop. I'm stuck on the part of the code that has to count with null statements in the for loop. It counts out the numbers but the cursor on the output screen stops after the nine and doesn't continue onto the next part of the code.

Heres my code:

cout << "Counting forward in increments of 1:" << endl;

for(inum = 0; inum < 10; inum++)
{
cout << " " << inum;
}


cout << endl << endl << "Counting backwards in increments of 0.5:" << endl;

for(fnum = 9; fnum > -.5; fnum-=.5)
{
cout << " " << fnum;
}


cout << endl << endl << "Counting from 0 to 50 in increments of 5:" << endl;

for(fnum1 = 0; fnum1 < 55; fnum1+=5)
{
cout << " " << fnum1;
}


cout << endl << endl << "Counting with null statements in increments of 1:" << endl;

inull = 0;
for( ; ; )
{
if(inull < 10)
{
cout << " " << inull;
inull++;
}
}


cout << endl << endl << "Counting with nested loops displayed in rows and columns:" << endl;

for(inum1 = 0; inum1 < 5; inum1++)
{
cout << " " << inum1;
for(inum2 = 0; inum2 < 3; inum2++)
{

}

}
Oct 22, 2009 at 2:19pm
for( ; ; )

is an infinite loop unless you have a break statement inside the loop.

and the body of your for loop stops outputting once inull reaches 9.
Topic archived. No new replies allowed.