Answer to Question #201300 in C for Ali khan

Question #201300

. 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


1
Expert's answer
2021-06-01T00:04:06-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS