Reverse array Learn programming C# Sharp

Lesson:

Arrays, Structures and Strings


Exercise:

Reverse array 22


Objetive:

Create a C# program to ask the user for 5 numbers, store them in an array and show them in reverse order.


Code:

using System;
public class exercise72
{
    public static void Main()
    {
        int[] numbers = new int[5];

        for (int i = 0; i < 5; i++)
        {
            Console.Write("Number {0} =  ", i + 1);
            numbers[i] = Convert.ToInt32(Console.ReadLine());
        }

        Console.WriteLine();
        for (int i = 4; i >= 0; i--)
        {
            Console.Write("{0} ", numbers[i]);
        }
    }
}