lab 8 / exercise 2

PHOTO EMBED

Sun Dec 25 2022 22:22:40 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #c

#include <stdio.h>
#include <stdlib.h>

/*2.	Write a C program that performs the following operations subsequently:
- Ask the user to enter the homework, midterm, and final exam grades of 10 students one by one and store them in an array (Create one array for each exam). Each grade is between 0 to 100.
- Calculate the overall grade and letter grade of each student. Homework represents the 30% of the overall grade, while midterm represents 30% and final represents 40%.
Student’s letter grade is determined as follows:
0 – 30 is equivalent to F
30	– 60 is equivalent to C
60	– 100 is equivalent to A.
- Your program should output the grade and letter grade of each student.*/


#include <stdio.h>
#include <stdlib.h>

int main() {
   int homework[10];
   int midterm[10];
   int final[10];
   float overall[10];
   char letter[10];
   int i;
   for(int i=0;i<10;i++)
   {
       printf("please enter homework, midterm and final grade of student %d: ",i+1);
       scanf("%d\n %d\n %d\n",&homework[i],&midterm[i],&final[i]);
   }
   
    // 0 – 30 is equivalent to F
   // 30	– 60 is equivalent to C
  //  60	– 100 is equivalent to A.

   for(int i=0;i<10;i++)
   {
       overall[i]=homework[i]*0.3+midterm[i]*0.3+final[i]*0.4;
       if(overall[i]>=60)
       letter[i]='A';
       else if(overall[i]>=30 && overall[i]<59)
       letter[i]='C';
       else
       letter[i]='F';
       
       printf("student %d overall grade is %f his or her grade letter is %c\n",i+1,overall[i],letter[i]);
   }
    return 0;
}
content_copyCOPY