Thursday 7 November 2013

While Loop

# include<iostream>
using namespace std;
void main()
{
int a;
a=0;
while(a<=10)
{
cout<<a<<endl;
a++;
}
}

This program is same as http://www.jdrana.blogspot.com/2013/10/include-include-void-main-int-i-fori0i.html......!
but this is done with the help of while loop
The while condition if tress control enter into while loop body,otherwise not.......!
As,For and while loop dones same thing,but While loop has its own space in c++ which we will discuss later........!
Output is:-
0
1
2
3
4
5
6
7
8
9
10
Note that 10 will also be printed because a is equal to 10....!
Feel free to give suggestions in comment box.......!
F

0 comments: