(in C++) I have to use the void function in this code and call it in main to pri
ID: 3940116 • Letter: #
Question
(in C++)
I have to use the void function in this code and call it in main to print the grades from int grades[] in descending order. this is what i have so far but i don't know what to do in the main function
#include<iostream>
using namespace std;
void sort(double x[], int n);
int main()
{
int grades[] = { 100, 95, 87,92,79 };
return 0;
}
void sort(double x[], int n)
{
int m;
double hold;
for (int k = 0; k <= n - 2; ++k)
{
m = k;
for (int j = k + 1; j <= n - 1; ++j)
if (x[j] > x[m])
m = j;
hold = x[m];
x[m] = x[k];
x[k] = hold;
}
return;
}
Explanation / Answer
#include using namespace std; void sort (int a[], int n) { for (int p = 0; pRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.