While Loop in C++ Language
In C++, while loop is used to repeat a block of the program several times. If the number of repetition is not fixed, It is suggested to use while loop rather than for loop.
Syntax -
Flowchart -
C++ While Loop Example -
Let us see a example using while loop to print the table of 1.
Output -
C++ Nested While Loop Example -
In C++, when we use while loop inside another while loop it is called as nested while loop. The inner while loop is executed fully when outer loop is executed once.
Let us see a example of nested while loop in C++ programming.
Output -
C++ Infinite While Loop Example -
We can also create infinite while loop by passing true value to the test condition.