Answer to Question #301530 in C# for T_K

Question #301530

Test Data :

Input 5 number of elements in the array :

element - 0 : 2

element - 1 : 5

element - 2 : 7

element - 2 : 3

element - 2 : 10

Expected Output:

The values store into the array are:

2 5 7 3 10

The values store into the array in reverse are :

10 3 7 5 2


1
Expert's answer
2022-02-23T14:18:06-0500


using System;
using System.Collections.Generic;
using System.Globalization;


namespace App
{
    class Program
    {


        static void Main(string[] args)
        {
            int[] elements = new int[5];
            for (int i = 0; i < elements.Length; i++)
            {
                Console.Write("Enter element - {0}: ", i);
                elements[i] = int.Parse(Console.ReadLine());
            }
            Console.WriteLine("The values store into the array are:");
            for (int i = 0; i < elements.Length; i++)
            {
                Console.Write("{0} ", elements[i]);
            }
            Console.WriteLine("\nThe values store into the array in reverse are:");
            for (int i = elements.Length - 1; i >= 0; i--)
            {
                Console.Write("{0} ", elements[i]);
            }




            Console.ReadLine();
        }


    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS