Q:

Write a program in C# Sharp to display the first 10 natural numbers

0

Write a program in C# Sharp to display the first 10 natural numbers

Sample Output:

Display the first 10 natural numbers:                                                                         
---------------------------------------                                                                        
The first 10 natural number are:                                                                              
1 2 3 4 5 6 7 8 9 10

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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");	
  }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now