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.
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.
Hence a for-loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.
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 to the next iteration(repetition of a process).
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<20whichholdstrueas10<20(forthefirstcase).Nowthebodyoftheloopisexecutedandwegettheoutput"Valueofa:10".Thentheupdateexpressionisexecutedwhichaddsthenumber1to'a'andthevalueof'a'getsupdatedto11andthesamestepsarefollowed(asabove)untilthevalueofvreacheslessthan20i.e19.