Problem
1. Write a program in C# Sharp to read user input number of values in an array
and display it in reverse order.
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ReverseArray
{
class Program
{
static void Main(string[] args)
{
//1. Write a program in C# Sharp to read user input number of values in
an array and display it in reverse order.//
int[] ArrayNum = new int [100];
int x, num;
Console.Write("How many number do you want to input? ");
num = Convert.ToInt32(Console.ReadLine());
Console.Write("\nEnter a number:\n");
for (x = 0; x < num; x++)
{
Console.Write("", x);
ArrayNum[x] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("\nThe numbers inputted are : \n");
for (x = 0; x < num; x++)
{
Console.Write("{0} ", ArrayNum[x]);
}
Console.WriteLine("\n\nThe numbers in reverse order :\n");
for (x = num - 1; x >= 0; x--)
{
Console.Write("{0} ", ArrayNum[x]);
}
Console.ReadKey();
}
}
}
Output: