Skip to main content

//While Loop

 //While Loop


CODE

👇

//Print number from 10 to 20.


  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int a = 10; //int use for integer value.
  6. while(a <= 20) //(a=10 <= 20) the condition is True; therefore excute conditional code.
  7.               //when condition is true then excute conditional code; otherwise loop body skipped.
  8. {
  9. //the body of while loop
  10. cout<<"the value of a is:"<<a<<endl; //"endl" use for linebreak. //"cout" use for print line.
  11. a++; // a++ for this condition 'a <= 20'. value increase upto 20.  
  12. }
  13. return 0;
  14. }


👉Execute👈


//Output

/*

the value of a is:10

the value of a is:11

the value of a is:12

the value of a is:13

the value of a is:14

the value of a is:15

the value of a is:16

the value of a is:17

the value of a is:18

the value of a is:19

the value of a is:20

*/





                                    //ThE ProFessoR