LOOP | WHILE LOOP

 

LEC:6

LOOP | WHILE LOOP

Source code:

/*

----------------while loop: A while loop statement repeatedly executes a target statement as long as a,

                given condition is true. -----------------

----- SYNTAX-------

    while(condition)

    {

        statement(s);

    }

*/

#include<iostream>

using namespace std;

int main()

{

    int n=1;

    cout<<"Enter the number";

    cin>>n;

    while(n<=10)

    {

     cout<<endl<<n;

     n++; // increment n by 1

    }

    return 0;

}

Comments

Popular posts from this blog

RunwayWithCode

web development Lectures

C++ Lectures