cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Another for loop question...
Another for loop question...
Apr 19, 2010 at 1:51am UTC
tysonc
(50)
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.
Apr 19, 2010 at 1:57am UTC
Disch
(13742)
'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"
;
Apr 19, 2010 at 4:36am UTC
Maimaje Bello Abdullahi
(52)
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.