settingsAccountsettings
Menusettings

Q: How can I print in C# numbers from 0 to 9

+3 votes

I need to know how can I print in C# (and Visual Studio) numbers from 0 to 9? tahnks

asked in C# category by user Jolie Ann
edited by user golearnweb

2 Answers

+1 vote

Try with while loop:

using System;

class PrintNumbers
{
    static void Main()
    {
        int i = 0;
        while (i < 10)
        {
            Console.WriteLine(i);
            i++;
        }
    }
}
answered by user nikole
edited by user golearnweb
+1 vote

Or with for loops:

using System;

class PrintNumbers
{
    static void Main()
    {
        for (int i = 0; i < 10; i++) //initialization, test, update
        {
            Console.WriteLine(i);
        }
    }
}
answered by user matthew44
edited by user golearnweb
...