while(condition)
{
Statements
.
.
[increment / or
decrement]
}
The while loop
executes code repeatedly until a condition is met. Without a false condition,
the statements in while loop are executed infinitely. Therefore, make use you
provide a stop point (false condition) where it should stop.
Example:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//wap to print first
ten numbers on the screen
namespace CABasics
{
class WhileExample15
{
static
void Main()
{
int
i = 1;
Console.WriteLine("First Ten Numbers Are");
while
(i <= 10)
{
Console.WriteLine(i
+ "");
i++;
}
Console.ReadLine();
}
}
}
|
Output:-
No comments:
Post a Comment