The while Loop in C++ :

while loop:

C language while Loop - The while loop is an entry control loop. A while loop has one control condition, and executes as long the condition is true. Here before executing the body of the loop, the condition is tested. The general syntax of the while loop is:

while(expression)
loop-body


Example :

  1. /* Description: Print 1 to 10 use while loop in C++ language */
  2. #include<iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int i=1;
  7. while( i <= 10 )
  8. {
  9. cout << "\n"<<i <<"\n";
  10. i++;
  11. }
  12. }

Output :

C++ language Print 1 to 10 use while loop

Next Update

Loading...

We Are Currently Working On Our Android Application Development and We already have two YouTube channels their name is CodeX or NightHawk. CodeX is for programming related videos and NightHawk is for online game streaming so please supporting us and Subscribe to our channels, Thank you