Challenge: Sort and Reverse Elements of an Array

Here is a coding challenge to test the concepts related to arrays and basic operations on arrays.

We'll cover the following

Problem statement #

Write a program that initializes an array with five integer elements as mentioned below under the input heading. Have the program sort the elements using sort() and then reverse the sorted elements using reverse().

Input #

Elements: 20 13 4 9 11

Output #

Sorted Elements: 4 9 11 13 20
Reversed Elements: 20 13 11 9 4 

Challenge #

This problem is designed for you to practice, so try to solve it on your own first. If you get stuck, you can always refer to the explanation and solution provided in the next lesson. Good luck!

Get hands-on with 1400+ tech skills courses.