Computer Applications

Write a program that reads ten integers and displays them in the reverse order in which they were read.

Java

Java Arrays

27 Likes

Answer

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

Answered By

7 Likes


Related Questions