Last active
November 30, 2022 06:29
-
-
Save Brianceasar/de37b4dfe01593d6c3af6a1d76fb7e80 to your computer and use it in GitHub Desktop.
Program that reads an integer number n from the console and prints all the numbers in the interval [1..n], each on a single line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace PrintNNumbers | |
{ | |
class Program | |
{ | |
static void Main (string[] args) | |
{ | |
int n; | |
Console.Write("Enter the first number n: "); | |
bool isInt = int.TryParse(Console.ReadLine(), out n); | |
if (isInt) | |
{ | |
for (int i = 1; i <= n; i++) | |
{ | |
Console.WriteLine(i); | |
} | |
} | |
else | |
{ | |
Console.WriteLine("Not a valid entry! n is not an integer!"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment