Write a program to reverse the array in C#
- Get link
- X
- Other Apps
Solution 1:
// C# code for the approach
using System;
class GFG {
// Driver Code
static void Main()
{
// Input array
int[] arr = { 1, 423, 6, 46, 34, 23, 13, 53, 4 };
int length = arr.Length;
int[] revArr = new int[length];
for (int i = 0; i < length; i++)
{
revArr[length - i -1] = arr[i];
}
Console.WriteLine("Reverse array: " + revArr);
Console.ReadKey();
}
}
Output
arr = { 4,53,13,23,34,46,6,423,1};
- Get link
- X
- Other Apps
Comments
Post a Comment