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

Introduction

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

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

Leave a Comment

x