-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverse_Array.java
More file actions
32 lines (30 loc) · 801 Bytes
/
Reverse_Array.java
File metadata and controls
32 lines (30 loc) · 801 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
28
29
30
31
32
import java.util.Scanner;
public class Reverse_Array
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int[] arr = new int[20];
int count,b,temp;
System.out.println("Enter how many number's you want to input:");
count=scanner.nextInt();
b=count-1;
System.out.println("Enter the Number's:");
for(int a=0;a<count;a++)
{
arr[a]=scanner.nextInt();
}
for(int a=0;a<count/2;a++)
{
temp=arr[a];
arr[a]=arr[b];
arr[b]=temp;
b--;
}
System.out.println("The Array in reverse order is :");
for(int a=0;a<count;a++)
{
System.out.println(arr[a]);
}
}
}