Answer to Question #251896 in C++ for meoww

Question #251896
Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer, calculate percentage and grade according to given conditions:
1
Expert's answer
2021-10-15T11:58:13-0400
#include <stdio.h>


int main(void) {
	int Physics,Chemistry,Biology,Mathematics,Computer;
	float percentage;


	printf("Enter mark of Physics subject: ");
	scanf("%d",&Physics);
	printf("Enter mark of Chemistry subject: ");
	scanf("%d",&Chemistry);
	printf("Enter mark of Biology subject: ");
	scanf("%d",&Biology);
	printf("Enter mark of Mathematics subject: ");
	scanf("%d",&Mathematics);
	printf("Enter mark of Computer subject: ");
	scanf("%d",&Computer);


	percentage=((Physics+Chemistry+Biology+Mathematics+Computer)/5.0);


	printf("\nPercentage: %.2f\n",percentage);


	if(percentage>100){
		printf("Invalid marks assigned");
	}else if(percentage>=90 && percentage<=100){
		printf("Grade: A\n");
	}else if(percentage>=80 && percentage<90){
		printf("Grade: B\n");
	}else if(percentage>=70 && percentage<80){
		printf("Grade: C\n");
	}else if(percentage>=60 && percentage<70){
		printf("Grade: D\n");
	}else if(percentage>=40 && percentage<60){
		printf("Grade: E\n");
	}else{
		printf("Grade: F\n");
	}


	getchar();
	getchar();
	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