Program for save values in dynamic array and display it into reverse order.

Hello,
This is program is for generate dynamic array and store values into that array.after that it will display you in reverse order without using inbuilt function.
Hope it will useful for you.

//Array.
    class Program
    {
        static void Main(string[] args)
        {
            int input = 0;
            int[] arrayvalue = new int[] { };

            Console.Write("Enter no of object that you want to display:-");
            input = Convert.ToInt32(Console.ReadLine());
            arrayvalue = new int[input];
            for (int i = 0; i <= arrayvalue.Length - 1; i++)
            {
                Console.Write("Element at {0} - ", i);
                arrayvalue[i] = Convert.ToInt32(Console.ReadLine());
            }
            //Display values that you have inserted
            for (int k = 0; k <= arrayvalue.Length - 1; k++)
            {
                Console.WriteLine(arrayvalue[k]);
            }
            //Display values in reverse order that you have inserted
            Console.WriteLine("Reverse values of given array");
            for(int j = arrayvalue.Length - 1; j >= 0; j--)
            {
                Console.WriteLine(arrayvalue[j]);
            }
            Console.ReadLine();
        }
    }

No comments:

Post a Comment

Please let me know if you have any feedback or doubts.

Jagged Array

What is Jagged Array? Jagged array is called as "array of arrays". when you need a data inside your array element at that time you...