Friday, December 12, 2008

While Statement-Simple Program

Definition:

1.For example if i want to print 1 to 10 , use while statement or for looping statement.
2.Until the condition satisfies while loop will execute, once it reaches the condition it will come out from the loop.

Example:


class Program
{
static void Main(string[] args)
{

int i = 0;
while (i!=5 ){
i++;
Console.WriteLine(i);
Console.ReadLine();
}
}
}


Output:
1
2
3
4
5

No comments: