18
Question Question 18
Write a program that reads ten integers and displays them in the reverse order in which they were read.
import java.util.Scanner;
public class KboatSDAReverse
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int arr[] = new int[10];
System.out.println("Enter 10 integers:");
for (int i = 0; i < 10; i++) {
arr[i] = in.nextInt();
}
System.out.println("Integers in reverse order:");
for (int i = 9; i >= 0; i--) {
System.out.print(arr[i] + " ");
}
}
}Output
