settingsAccountsettings
By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy
Menusettings

Q: How to write a program in C# (C Sharp) to print the numbers 3, 303 and 3003

+5 votes
I need to write a program in C# (C Sharp) to print the numbers 3, 303 and 3003, each at a separate line.
asked in C# category by user Jolie Ann

1 Answer

+2 votes
 
Best answer

FIRST - MOST COMMON WAY:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class WriteNumbers
{
    static void Main()
    {
        Console.WriteLine(3);
        Console.WriteLine(303);
        Console.WriteLine(3003);
    }
}

 

SECOND WAY - with a place holder + \n insert new line:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class WriteNumbers
{
    static void Main()
    {
        Console.WriteLine("{0}\n{1}\n{2}", 3, 303, 3003);
    }
}
answered by user hues
edited by user golearnweb
Thank you very nmcuh!
...