A `for` loop is a repetitive statement that is used to check for some condition and then, based upon the condition a block of code, is executed repeatedly until the specified condition is satisfied.
It is typically used when the number of iterations are known; contrasting to that of a while loop where, generally, the number of iterations is unknown.
The `for` loop is distinguished from other looping statements through an explicit loop counter or loop variable which allows the body of the loop to know the exact sequencing of each iteration.
Next the condition is evaluated. If it holds true, the body of the loop is executed. If it holds false, the body of the loop does not execute and flow of control jumps outside the loop.
The increment statement is used to alter the loop variable by using simple increment operations and executes after the completion of the body of the loop.
### update
The update statement is used to alter the loop variable by using simple operations like addition, subtraction, multiplication or division and executes after the execution of the body of the loop.
You will often see an increment operation as the update statement (e.g. i++, count++). This is often seen as one of the distinguishing features and possible name sources for the C++ language.
Here, the initialization condition is first set to `a=10`. The loop first checks for this condition. It then checks for the condition expression i.e. `a < 20` which holds true as `10 < 20` (for the first case). Now the body of the loop is executed and we get the output "Value of a: 10". Then the update expression is executed which adds the number 1 to 'a' and the value of 'a' gets updated to 11 and the same steps are followed (as above) until the value of v reaches less than 20 i.e 19.
This C-style for-loop is commonly the source of an infinite loop since the fundamental steps of iteration are completely in the control of the programmer. In fact, when infinite loops are intended, this type of for-loop can be used (with empty expressions), such as: