Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a well documented C Programming that will get eight numeric grades from a

ID: 3707420 • Letter: W

Question


Write a well documented C Programming that will get eight numeric grades from a user and store them in an array. The array should be passed to a function that will sort the array, then the main function should print the eight scores in ascending order along with the corresponding letter grade for each score. The letter grade for each score should be determined and printed in a function that accepts the number grade as an argument. After all numeric and letter grades are displayed, the average numeric grade should be shown to one decimal place with a percent sign, as well as the letter grade that corresponds to the average. The letter grades should be displayed by a single function that is called nine different times. The program must use at least 2 functions other than the main function: one function that sorts the array; and one function that accepts a numeric grade and prints the corresponding letter grade. Both can be void functions. Use hypothetical scales from 0 to 100 for the letter grades A, B, C, D, and F. See below example: Example Enter grade 1: 88 Enter grade 2: 100 Enter grade 3: 93 Enter grade 4: 76 Enter grade 5: 85 Enter grade 6: 88 Enter grade 7: 82 Enter grade 8: 82 Sorted grades: 76-C 82-B 82 B 85 B 88-B 88- B 93A 100 A Grade average of the 8 grades: 86.8% -B

Explanation / Answer

#include<stdio.h>
#include<math.h>
//Function Declaration
void sortGrades(int *grd,int nog);
void displayGrade(int grade);
//Function Definations
void sortGrades(int *grd,int nog){
   int i,j,temp;
//Nested Loop for sorting the grades in ascending order
    for (i = 0; i < nog; i++)
     {
       for (j = i + 1; j < nog; j++)
          {
           if (grd[i] > grd[j])
                {
                    temp = grd[i];
                    grd[i] = grd[j];
                   grd[j] = temp;
                 }

          }

     }

  

}
void displayGrade(int grade){
   if(grade<30){
       printf("- F");
   }
   else if(grade<40){
       printf("- E");
   }
   else if(grade<50){
       printf("- D");
   }
   else if(grade<80){
       printf("- C");
   }
   else if(grade<90){
       printf("- B");
   }
   else if(grade<100){
       printf("- A");
   }
}


int main()
{
    int i=0, grades[8] ,nog=8,totalGrades=0 ;
    float avgGrade;
   //loop for accepting grades
    for(i = 0; i < 8; i++) {
       printf("Enter Grade %d : ",i+1);
        scanf("%d",&grades[i]);
        printf(" ");
    }
    //calling function sortGrades for sorting the array
    sortGrades(grades,nog);
    for(i = 0; i < nog; i++) {
       totalGrades = totalGrades + grades[i];
     
    }
    avgGrade = totalGrades/8;
    printf("Sorted Grades: ");
    for(i = 0; i < nog; i++) {
       printf("grades[i] ");
       displayGrade(grades[i]);
       printf(" ");
     
    }
    printf("Grade average of the 8 grades: %.1f%% ",avgGrade);
    //ceil will round of the float
    avgGrade=ceil(avgGrade);
  
    displayGrade(avgGrade);
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote