- Course
- Arrays
- Array in reverse order
Array in reverse order
Last updated:
8/23/2020
⁃
Difficulty:
Intermediate
Create a C# program that asks the user for 5 integers to store them in an array of integers and display them in reverse order.
Input
3
5
1
6
3
Output
3 6 1 5 3
Solution
using System;
public class ArrayReverseOrden
{
public static void Main(string[] args)
{
int total = 5;
int[] numbers = new int[total];
for (int i = 0; i < total; i++)
{
numbers[i] = Convert.ToInt32(Console.ReadLine());
}
Array.Reverse(numbers);
for (int i = 0; i < total; i++)
{
Console.Write("{0} ", numbers[i]);
}
}
}