Another for loop question...

Ok, how to I get something to output on a certain iteration of my loop? Lets say I have:
for (numLoops = 0; numLoops < 10; numLoops++)

What what I do if I wanted to output something on the 6th iteration?

Thanks for the help.
'numLoops' increases by 1 each iteration, so to see which iteration you're on, you can just check numLoops.

1
2
if(numLoops == 5)
  cout << "whatever";
yes, if statement can help you to output something on any iteration you may like.

1
2
3
4
if(numLoops == 5)
{
     cout<<"Iteration five"<<endl;
}



Good luck!
Topic archived. No new replies allowed.