For Loop

suggest change

A For Loop is great for doing things a certain amount of time. It’s like a While Loop but the increment is included with the condition.

A For Loop is set up like this:

for (Initialization; Condition; Increment)
    // Code
Initialization - Makes a new local variable that can only be used in the loop.

Condition - The loop only runs when the condition is true.

Increment - How the variable changes every time the loop runs.

An example:

for (int i = 0; i < 5; i++)


0 1 2 3 4

You can also leave out spaces in the For Loop, but you have to have all semicolons for it to function.

int input = Console.ReadLine();    

for ( ; input < 10; input + 2)

Output for 3:

3 5 7 9 11

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents