76 337
Assignments Done
Successfully Done
In May 2019

Answer to Question #16420 in C++ for Andrew Lowrey

Question #16420
Write a program that takes in 10 (ten) test grades, display the unsorted grades, display the grades in ascending order, and then display the grades in descending order.
Expert's answer

#include <stdio.h>
#include <stdlib.h>

int grades[104] ;

int compare (const void * a, const void * b)
return ( *(int*)a - *(int*)b );

int main ()
int n;
for(int i=0;i<10;i++){
printf("Enter grade %d: ",(i+1));
qsort (grades, 10, sizeof(int), compare);
for (n=9; n>=0; n--)
printf ("%d ",grades[n]);
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions