C++ While Loop Control Structure

In this Tutorial we will understand and learn the working of While Loop statements in C++ programming language.

While Loop statements in C++ is an iterative looping control structure that executes and block of code until a certain condition is true.
Unlike For Loop, it is not necessary to know the number of iterations before hand. While conditions can contain conditional statements and the Loop will run until those statements are TRUE

Syntax of While Loop statements in C++
Flow chart diagram of While loop in C++

 

While Loop statements in C++

Working of While Loop
  • The while loop evaluates the test condition
  • If the test condition is true, code inside the body of while loop is executed, else the flow control exits the loop block.
  • After first iteration, the test condition is evaluated again. This process goes on until the test condition is false.
  • When the test condition is false, while loop is terminated.
While Loop sample program in C++

Run Online

Watch it on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *