C++ for loop

It is an entry-control loop. For loops work like the corresponding while loop that it will execute a block of the statement until the specified condition returns false.
It has three computing steps:

  • The first is the initialization of the counter variable.
  • The second expression is test or condition check for true or false, which is evaluated to see if the body of the loop should be executed or not.
  • The third expression is increment or decrement of countered variable which is performed at the end of every iteration/repetition of the loop.

Syntax:

Example

Output:



1 thought on “C++ for loop”

Comments are closed.