Like other programming languages, array in C# is a group of similar types of elements that have contiguous memory location. In C#, array is an object of base type System.Array. In C#, array index starts from 0. We can store only fixed set of elements in C# array.
There are 3 types of arrays in C# programming:
In this tutorial we will learn more about Single Dimensional or 1D Arrays.
To create single dimensional array, you need to use square brackets [] after the type.
int[] arr = new int[5]; //creating array of size 5
You cannot place square brackets after the identifier.
NOTE:
We can access the element of an array using the index number. Here is the syntax for accessing elements of an array,
// access array elements array[index]
Similarly, we can print the contents of the any ith cell with the following code:
System.Console.Write(array[i]);
Similarly, we can get the size of any array using the following code:
arrayName.Length
Task:
Take N integers as an input and store them in an array and then print the array in reverse format.
Problem Constraints
1 <= N <= 105
1 <= Array Elements <= 109
Input Format
First line contains a single integer N
Next N lines each contains a single integer denoting the array elements.
Output Format
Output N lines denoting the reverse of the inputted array.
Example Input
Input 1:
5 2 1 11 13 14
Input 2:
2 12 11
Example Output
Output 1:
14 13 11 1 2
Output 2:
11 12