-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverse.java
More file actions
27 lines (27 loc) · 783 Bytes
/
Copy pathReverse.java
File metadata and controls
27 lines (27 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.Scanner;
public class ReverseArray
{
public static void main(String[] args)
{
int []arr = new int[50]; //declaration and instantiation
int n;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the size of Array: ");
n = sc.nextInt();
System.out.println("Enter the "+n+" Elements in The Array: ");
for(int i = 0; i < n; i++)
{
arr[i] = sc.nextInt();
}
System.out.println("The Array is: ");
for(int i = 0; i < n; i++)
{
System.out.println(arr[i]);
}
System.out.println("The Reverse Array is: ");
for(int i = n - 1; i >= 0; i--)
{
System.out.println(arr[i]);
}
}
}