Free Hosting

While Loops in C++



1.htm
1.While Loop:-
       While(Condition)
       {
             ------;
             ------;
             ------;
        }
If the condition is true then the statements written in curly braces will be repeated until the condition will go false. 

While loop is started with a condition check then the code in curly braces will 
be executed.
Example:-
Program:-
#include<iostram.h>
#include<Conio.h>
class looptest
{
        public:
                    void testloop()
                    {
                           int i=0;
                            while(i<10)
                            {
                                    cout<<i<<endl;
                                    i=i+1;
                             }
                      }
};

void main()
{
           looptest t;
           t.testloop();
           getch();
}


-->

0 comments:

Blogger Template by Clairvo