do
{
Statements
.
.
[increment / decrement]
}while(condition);
The do while
loop tests the condition at the bottom of the loop. It executes at
least one time although the condition is not true.
Example:-
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Text;
//wap
to print first 10 numbers on the screen using do while loop
namespace CABasics
{
class dowhile17
{
static
void Main(string[]
args)
{
int
i = 1;
Console.WriteLine("First 10 Numbers are");
do
{
Console.WriteLine(i);
i++;
} while
(i <= 10);
Console.ReadLine();
}
}
}
|
Output:-
No comments:
Post a Comment