38.3k views
3 votes
Create a Reverse application that stores the number corresponding to the element's index in an integer array of 10 elements. For example, the second element, which has index 1, should store 1. The application should then display the title "Countdown" and then list numbers stored in the array in reverse order.

User Zechdc
by
4.9k points

1 Answer

3 votes

Answer:

Written in Java

public class MyClass {

public static void main(String args[]) {

int [] myarray = new int[10];

for(int i = 0;i<10;i++) {

myarray[i] = i;

}

System.out.println("Countdown");

for(int i = 9;i>=0;i--) {

System.out.println(myarray[i]);

}

}

}

Step-by-step explanation:

This line declares the array

int [] myarray = new int[10];

The following iteration inserts 0 to 9 into the array

for(int i = 0;i<10;i++) {

myarray[i] = i;

}

This line prints "Countdown"

System.out.println("Countdown");

The following iteration prints the array in reverse order

for(int i = 9;i>=0;i--) {

System.out.println(myarray[i]);

}

User Crobar
by
4.3k points