Asked Sep 18, 2019

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).


Expert Answer

Step 1


//include the required header files
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)
//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

Check out a sample Q&A here.

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


Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: Code should be in C++ Absolute Value Template: Write a function template that accepts an argument an...

A: Since Function Templates are used to handle all possible data types you can say generic data type at...


Q: The symmetric difference of two sets S1 and S2 is defined as S1 ⊝ S2 = {x : x ∈ S1 or x ∈ S2, but x ...

A: Solution:Given that,The symmetric difference between two sets such as “S1” and “S2” can be expressed...


Q: Consider the following grammar in BNF (start symbol is ) Which of the following sentences are in the...

A: Backus-Naur Form (BNF):BNF is a formal mathematical method to define the syntax of the programming l...


Q: Programming in C language.

A: Note:The below given program has been compiled using "" online compiler.


Q: 4.23 (Financial application: payroll) Write a program that reads the following information and print...

A: C code#include&lt;stdio.h&gt;#include&lt;string.h&gt; int main(){char employeeName[20]="";double hou...


Q: do big data could replace the artistic vision of a creative director? and why?

A: Justification:“Yes”, big data replace the artistic vision of a creative director.


Q: Write a PL/SQL block to retrieve and display the students enrolled in a course.

A: Click to see the answer


Q: Write a class in java with the name AgeMessages , which does the following:a. Ask the user to enter...

A: The algorithm for the program would be as below:Declare one float variable for accepting user inputP...


Q: Use Eclipse for do this program. Show the output of the following statements.a) System.out.printf("a...

A: The program has the following algorithm:a) The statement print the amount in floating point and expo...