Write a program in C to take a list of total scores from use

Write a program in C to take a list of total scores from user as input and determines the grade for CSCI 1320students from those total scores. You need to first prompt the user for the student count in that section. Next, start taking total scores and put them into an array of float. After taking all scores, you check which grade the student has got based on the input score stored in the array. If the score is between or 90 and 100 then it\'s an \'A\' grade, if it\'s between or 80 to 89 then \'B\' grade and so on. -You need to do the followings: Properly comment The program Briefly explain how you have solved the problem.

Solution

Please find the required program along with its output. Please see the comments against each line to understand the step.

#include \"stdio.h\"

int main(void) {
   int i,n;
printf(\"\ Enter the no:of students: \");
scanf(\"%d\",&n);   //read the no:of students
float score[n];   //initialize score array
printf(\"\ Enter %d students total scores: \",n);
for(i=0; i<n; i++){   //read the n no:of students total scores
   scanf(\"%f\",&score[i]);
}
  
printf(\"\ The grades of students are:\");
char grade;
for(i=0; i<n; i++){   //find the grade of n no:of students, and print it
   if(score[i] >= 90 && score[i] < 100)   //if the score is greater than 90 and less than 100
       grade = \'A\';
   else if(score[i] > 80)   //else if the greater than 80
       grade = \'B\';
   else if(score[i] > 70)   //else if the greater than 70
       grade = \'C\';
   else if(score[i] > 60)   //else if the greater than 60
       grade = \'D\';
   else if(score[i] < 40)   //else if the less than 40
       grade = \'F\';
      
   printf(\"\ Student %d : %c\",(i+1),grade);
}
return 0;
}

-----------------------------------------------------------------------------------

Firstly you have to read the no:of students the user needs to find grades, then according to the no:of students, read all that \'n\' no:of students total scores into a float array. After that iterate over each score in the array and determine the grade with the help of if-else statements, and finally print each students grades.

-----------------------------------------------------------------------------------

OUTPUT:

 Write a program in C to take a list of total scores from user as input and determines the grade for CSCI 1320students from those total scores. You need to firs

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site