C# Sharp Exercises: Display first 10 natural numbers
C# Sharp For Loop: Exercise-1 with Solution
Write a program in C# Sharp to display the first 10 natural numbers.
Pictorial Presentation:
Sample Solution:
C# Sharp Code:
using System;
public class Exercise1
{
public static void Main()
{
int i;
Console.Write("\n\n");
Console.Write("Display the first 10 natural numbers:\n");
Console.Write("---------------------------------------");
Console.Write("\n\n");
Console.WriteLine("The first 10 natural number are:");
for (i=1;i<=10;i++)
{
Console.Write("{0} ",i);
}
Console.Write("\n\n");
}
}
Sample Output:
Display the first 10 natural numbers: --------------------------------------- The first 10 natural number are: 1 2 3 4 5 6 7 8 9 10
Flowchart:
C# Sharp Code Editor:
Contribute your code and comments through Disqus.
Previous: C# Sharp programming exercises: For Loop
Next: Write a C# Sharp program to find the sum of first 10 natural numbers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework