Programming

for LOOP IN C++…

for LOOP IN C++

for Loop:

In for loop we initialize the counter of the loop within its syntax along with the condition and the increment or decrement statement.

It works same as the other loop the only difference is the syntax but it is essential to use for loop instead of while loop.

Syntax:

In for loop we initialize ; give condition , and increment or decrement within for loop round brackets.

 

for (initialize ; condition ; increment or decrement)

 

so it is a little bit more perfect than the while loop. because the integer counter creates and destroyes within the for loop.

 

 

 

Example 1:

Output:

Example 2:

Output:

1 Comment

1 Comment

Leave a Reply

Your email address will not be published.

Most Popular

To Top