class Program
{
static void Main(string[] args)
{
int i;
i = 1;
while (i < 10)
{
Console.WriteLine(i);
i++;
}
Console.WriteLine("\nFor Loop\n");
for (int j = 1; j <= 10; j++)
{
Console.WriteLine(j);
}
Console.WriteLine("\nDo-while\n");
i = 1;
do
{
i++;
Console.WriteLine(i);
} while (i <= 10);
}
}
Remark : As you have seen in C/C++ loop . Do-while loop is same as there . It run at least one time when condition is false. So do-while loop guarantee to at least one time .
{
static void Main(string[] args)
{
int i;
i = 1;
while (i < 10)
{
Console.WriteLine(i);
i++;
}
Console.WriteLine("\nFor Loop\n");
for (int j = 1; j <= 10; j++)
{
Console.WriteLine(j);
}
Console.WriteLine("\nDo-while\n");
i = 1;
do
{
i++;
Console.WriteLine(i);
} while (i <= 10);
}
}
Remark : As you have seen in C/C++ loop . Do-while loop is same as there . It run at least one time when condition is false. So do-while loop guarantee to at least one time .
No comments:
Post a Comment