Problem: Numbers from 1 to 20
Write a C# console program that prints the numbers from 1 to 20 on separate lines on the console.
Video: Problem "Numbers from 1 to 20"
Watch a video lesson to learn how to solve the "Numbers from 1 to 20" problem step by step: https://youtu.be/8Qne7CBM2SQ.
Hints and Guidelines
Create a C# console application with name “Nums1To20
”:
Inside the static void Main()
method write 20 commands Console.WriteLine(…)
, each on a separate line, in order to print the numbers from 1 to 20 one after another. Some of you may be wondering 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:
1
2
…
20
Testing in the Judge System
Test your solution here: https://judge.softuni.org/Contests/Practice/Index/503#2.
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#".