The while loop is repeats a statement or block while its controlling expression is true.The condition can be any Boolean expression.
The body of the loop will be executed as long as the conditional expression is true. When condition becomes false, control passes to the next line of code immediately following the loop.
Syntax:
while(Condition)
{
// body of loop;
// Increment (or) Decrement;
}
The program is a simple implementation of the while loop in C++.
/* Looping Statement 1.While 2.do While 3.for 4.for each */ #include<iostream> using namespace std; int main() { int i=1,n; cout<<"\nEnter The Limit : "; cin>>n; while(i<=n) { cout<<"\n"<<i; i++; } return 0; }
Enter The Limit : 10 1 2 3 4 5 6 7 8 9 10To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions