. If we have the structure of the student given as and suppose we have ten students
 struct student
{
 char name[20];
 int eng;
 int math;
 int phys;
 double mean;
};
a) We want to calculate mean of three subjects of each person.Â
b) We want to determine grade based on mean of three subjects and table shown inÂ
below. Confirm by executing it.
Mean Grade
90 <= x <= 100 S
80 <= x < 90 A
70 <= x < 80 B
60 <= x < 70 C
x < 60 D
#include <stdio.h>
struct student{
  char name[20];
  int eng;
  int math;
  int pys;
  double mean;
};
int main()
{
  struct student stu;
  Â
  printf("enter the data of student\n");
  for(int i=1;i<=10;i++){
    printf("\nenter name of %d student= ",i);
    scanf("%s",stu.name);
    printf("\nenter marks in english= ");
    scanf("%d",&stu.eng);
    printf("\nenter marks in math= ");
    scanf("%d",&stu.math);
    printf("\nenter marks in physics= ");
    scanf("%d",&stu.pys);
    stu.mean=(double)(stu.math+stu.eng+stu.pys)/3;
    printf("\nMean of these three subject is= %lf",stu.mean);
    if(stu.mean>=90 && stu.mean<=100)Â
      printf("\nGrade= S");
    else if(stu.mean>=80 && stu.mean<90)Â
      printf("\nGrade= A");
    else if(stu.mean>=70 && stu.mean<80)Â
      printf("\nGrade= B");
    else if(stu.mean>=60 && stu.mean<70)Â
      printf("\nGrade= C");
    else
      printf("\nGrade = D");
  }
  return 0;
}
Comments
Leave a comment