C# Do While Loop with examples

In this C# program, we will see Do While Loop with examples.

C# Do While Loop with examples Code:

private static void Main(string[] args)
        {
            Console.Write("Enter a number between 1-10 : ");
            int input = int.Parse(Console.ReadLine());

            if (input <= 10 && input > 1)
            {
                int i = 1;
                do 
                {
                    Console.Write(i.ToString() + ",");
                    i++;
                }while (i <= input); 
            }
            else
            {
                Console.Write("Invalid number entered.");
            }

            Console.ReadLine();
        }

C# Do While Loop with examples Output:

CSharp-Do While-Loop-with-examples

 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice