Do while loop : Do While « Statement « C# / CSharp Tutorial






A do-while loop will always execute at least once.

The general form of the do-while loop is

do {
statements;
} while(condition);
using System;

class MainClass
{
    public static void Main()
    {
        int n = 0;
        do
        {
            Console.WriteLine("Number is {0}", n);
            n++;
        } while (n < 10);
    }
}
Number is 0
Number is 1
Number is 2
Number is 3
Number is 4
Number is 5
Number is 6
Number is 7
Number is 8
Number is 9








4.6.Do While
4.6.1.Do while loop
4.6.2.Display the digits of an integer in reverse order with do while loop
4.6.3.Using break to exit a do-while loop
4.6.4.Use the do while statement to implement Newton's method for finding the square root of a number
4.6.5.Do / while loop with a console read