004-004-011

Reversing Array Element Assignment

Medium

Problem Description

Reversing Array Element Assignment

In this problem, you will create a program that reads an array size and elements from standard input, copies the elements into a new array in reverse order, and displays both the original and reversed arrays to standard output.

Learning Objective: Apply array index manipulation to reverse element order

Overview

Create a program that reads an array from input, copies its elements in reverse order into a new array, and prints both.

Input Format

N
a1 a2 ... aN
  • Line 1: array size N (1 ≤ N ≤ 10)
  • Line 2: N space-separated integers

Specifications

  1. Use Scanner to read array size N
  2. Read N integers into an int[] array
  3. Create a new array of the same size
  4. Copy elements in reverse order into the new array
  5. Print both the original and reversed arrays

Output Format

Original: a1 a2 ... aN
Reversed: aN ... a2 a1

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up