# In C++Sort an array from largest to smallest (you may use one of the sorts we did, you just have to change it so that it goes from largest to smallest instead).

Question
1 views

In C++

Sort an array from largest to smallest (you may use one of the sorts we did, you just have to change it so that it goes from largest to smallest instead).

check_circle

Step 1

Program:

#include<iostream>
using namespace std;

//definition of main method
int main ()
{
//declare the required variables
int arr[5];
int i, j, temp;

//get the input numbers from the user
cout<<"Enter 5 numbers : ";
for (i = 0; i < 5; ++i)
cin>>arr[i];

//sort the numbers
for (i = 0; i < 5; ++i)
{
for (j = i + 1; j < 5; ++j)
{
if (arr[i] < arr[j])
{
//swap the numbers
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
//display sta...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in