C++ while Loop Statement

The while loop is an iterative control statement. A while loop repeatedly executes loop’s statement(s) several times as a given condition is true. Execution of loop is terminated when the condition of while loop becomes false and execute code after the loop.


Working Process Of While Loop

  1. While loop first checks the condition applied.
  2. If the condition of a while loop is satisfied (true), statement(s) within the loop is executed. If condition of a while loop is not satisfied (false), program execution is terminated from loop and statement after the loop is executed.
  3. Repeatedly check the loop condition and execute according to step 2.

C++ while loop Example

This program prints counting from 1 to 10.


Pin It on Pinterest

Share This