Showing posts with label How to find out the reverse of an array. Show all posts
Showing posts with label How to find out the reverse of an array. Show all posts

How to find out the reverse of an array


Display Array in Reverse form

Reverse the element of array  


class Program
    {
        public static void ReverseAnArray(int[] arr)
        {
            for (int i = arr.Length - 1; i >= 0; i--)
            {
                Console.Write(arr[i]+"\t");
            }

        }
      
        static void Main(string[] args)
        {
            Console.WriteLine("How to find out the reverse of an array \n");

            Console.WriteLine("Enter array Size");
            int arraysize = Convert.ToInt32(Console.ReadLine());
            int[] arr = new int[arraysize];

            Console.WriteLine("Enter the array Value");
            for (int i = 0; i <= arraysize - 1; i++)
            {
                arr[i]= Convert.ToInt32(Console.ReadLine());
            }

            Program.ReverseAnArray(arr);
            Console.ReadLine();
           
        }
    }

Share:

Popular

Tags

Mobile

Recent Posts