Cpp For Loop
# C++ for Loop
[ C++ Loops](#)
The **for** loop allows you to write a loop control structure that executes a specific number of times.
## Syntax
The syntax of a **for** loop in C++:
for ( init; condition; increment ){ statement(s);}
The control flow of a for loop is as follows:
1. The **init** step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You can omit this statement as long as a semicolon is present.
2. Next, the **condition** is evaluated. If it is true, the loop body is executed. If it is false, the loop body is not executed, and control flow jumps to the next statement immediately following the for loop.
3. After the for loop body executes, control flow jumps back to the **increment** statement. This statement allows you to update the loop control variable. This statement can be omitted as long as a semicolon is present after the condition.
4. The condition is evaluated again. If it is true, the loop executes, and the process repeats (loop body, then increment step, then re-evaluate condition). When the condition becomes false, the for loop terminates.
## Flowchart

## Example
## Example
#includeusing namespace std; int main(){// for loop execution for(int a = 10; a<20; a = a + 1){cout<<"a Value:"<<a<<endl; }return 0; }
When the above code is compiled and executed, it produces the following result:
a Value: 10 a Value: 11 a Value: 12 a Value: 13 a Value: 14 a Value: 15 a Value: 16 a Value: 17 a Value: 18 a Value: 19
### Range-based for loop (C++11)
The for statement allows for simple range iteration:
int my_ar
YouTip