for

The for loop will iterate through the loop, starting from the specified initial condition and will iterate through the statements enclosed within the { code block } until the test is false. The initial condition, test and iterator are separated with a ;

 

for (initialiser; test; iterator ) {
statements ;
}

 

Compile & run:

The value of i is now: 0
The value of i is now: 1
The value of i is now: 2
The value of i is now: 3
The value of i is now: 4

Leave a Reply