Test Data :
Input 5 number of elements in the array :
element - 0 : 2
element - 1 : 5
element - 2 : 7
element - 2 : 3
element - 2 : 10
Expected Output:
The values store into the array are:
2 5 7 3 10
The values store into the array in reverse are :
10 3 7 5 2
using System;
using System.Collections.Generic;
using System.Globalization;
namespace App
{
class Program
{
static void Main(string[] args)
{
int[] elements = new int[5];
for (int i = 0; i < elements.Length; i++)
{
Console.Write("Enter element - {0}: ", i);
elements[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine("The values store into the array are:");
for (int i = 0; i < elements.Length; i++)
{
Console.Write("{0} ", elements[i]);
}
Console.WriteLine("\nThe values store into the array in reverse are:");
for (int i = elements.Length - 1; i >= 0; i--)
{
Console.Write("{0} ", elements[i]);
}
Console.ReadLine();
}
}
}
Comments
Leave a comment