Jump to content

Cplusplus: Difference between revisions

250 bytes added ,  11 December 2007
no edit summary
No edit summary
No edit summary
Line 354: Line 354:


This produces the same result, except in a much handier format. There are three things you declare when creating a for loop: a variable, what condition must be met for the loop to continue cycling, and what happens at the end of a loop. a is the initialised variable, the loop will continue until it reaches 100 and at the end of each loop, a is incremented by 1. Simple.
This produces the same result, except in a much handier format. There are three things you declare when creating a for loop: a variable, what condition must be met for the loop to continue cycling, and what happens at the end of a loop. a is the initialised variable, the loop will continue until it reaches 100 and at the end of each loop, a is incremented by 1. Simple.
To end a loop immediately, issue the following command in your code
break;
For example, if you want the loop to end early when a certain condition is met, just use an if statement inside the loop and have the loop break if this condition is met.


[[Category:Helpdesk]]
[[Category:Helpdesk]]
244

edits