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.
1
Expert's answer
2012-10-16T11:43:16-0400
#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)); scanf("%d",&grades[i]); } qsort (grades, 10, sizeof(int), compare); for (n=9; n>=0; n--) printf ("%d ",grades[n]); scanf("%d",&grades[0]); return 0; }
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments