My 2 Cents How To Use The For Loop In C++

Swati Mishra

Yellow Belt
The For loop provides a compact way of specifying the statements that control the repetition of the steps within the loop. In the For loop, statement are not written within the body of the loop, statement are written at the top. The keyword For followed by the parenthesis and its containing three expression, which is separate by the semicolon. These are the initialization, the test expression and the increment or decrement expression.

Syntax

For (initialization; test expression; increment/decrement expression)
{
Statements;
}
 

krishatg

Yellow Belt
You can further extend it to different types of loops i.e.
While, do while, For
Out of which while and for are entry restricted loops and do while is exit restricted loop. And also loops can be nested that means we can use one loop inside another loop.
 
Top