I'm trying to sort an array of type double in C but I am not getting the expected output. It appears to be sorting the memory addresses instead of the actual values. I have tried changing the vairables to (*grade[i]) but then I get a "invalid type argument of unary *" error. Here is the snipit of code in question.
void sortGrade(double grade[], int n){
int i, j, swapped;
double temp;
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (grade[i] < grade[j])
{
temp = grade[i];
grade[i] = grade[j];
grade[j] = temp;
}//end if
}//end inner for
}//end outer for
printf("After sort:\nGrade\n");
for (i = 0; i < n; ++i)
{
printf("%d\n", grade[i]);
}//end for
}//end sortGrade
Any help would be greatly appreciated. Full disclosure, this is for school, but the assignment has already been submitted, now I'm just trying to figure out how to actually make it work.
%for%gto print floating-point numbers.:)