Q:

Write C# program to print all natural numbers in reverse order

0

Write C# program to print all natural numbers in reverse order

All Answers

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

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
public class csharpExercise
{
    static void Main(string[] args)
    {
 
        int i, num;
 
        //Read a number from user
        Console.Write("Enter any number: ");
        num = Convert.ToInt32(Console.ReadLine());
 
        /*Running loop from the number entered by user,
          and Decrementing by 1*/
        for (i = num; i >= 1; i--)
        {
            Console.WriteLine("\n" +  i);
        }
 
        Console.ReadLine();
    }
}

Result:

Enter any number: 5

5

4

3

2

1

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

total answers (1)

Write C# program to print sum of digits enter by u... >>
<< Write C# program to print multiplication table of ...