Changes

Jump to: navigation, search

C Sharp Looping - The for Statement

12 bytes added, 17:01, 17 January 2008
Continuing for Loops
== Continuing for Loops ==
Another useful statement for use in loops in the ''continue'' statement. When the execution process finds a ''continue '' statement in any kind of loop it skips all remaining code in the body of the loop and begins execution once again from the top of the loop. Using this technique we can construct a ''for '' loop which outputs only even numbers between 1 and 9:
<pre>
</pre>
In the example, if i is not divisible by 2 with 0 remaining the code performs a ''continue'' sending execution to the top of the ''for '' loop, thereby bypassing the code to output the value of i. This will result in the following output:
<pre>

Navigation menu