Problem: numbers from 1 to 20

Write a C# console program, which prints the numbers from 1 to 20 on separate rows on the console.

Hints and Guidelines

We create a C# console application with name “Nums1To20“:

Inside the static void Main() method we write 20 commands Console.WriteLine(…), each on a separate row, in order to print the numbers from 1 to 20 one after another. Some of you must be aksing themselves if there is a smarter way. Relax, there is, but we will mention it later on.

Now we start the program and we check if the result is what it is supposed to be:


Testing in the Judge System

Test your solution here:

Now think whether we can write the program a smarter way, so we don't repeat the same command 20 times. Seek out information on the Internet about "for loop C#".

results matching ""

    No results matching ""