Write a program to Calculate Subject Marks and Percentage
0Hasnain AltafMay 06, 2022
Write a program to Calculate Subject Marks and Percentage
Q:-Write a program to Calculate Subject Marks and Percentage
#include
<stdio.h> int
main(){ float a,b,c,d,e,res; printf("Enter your first
subject marks\n"); scanf("%f",&a); if(a>100) { printf("\nPlease Enter
number less than 100"); printf("\nPlease re enter
first subject marks\n"); scanf("%f",&a); } printf("Enter your second
subject marks\n"); scanf("%f",&b); if(b>100) { printf("\nPlease Enter
number less than 100"); printf("\nPlease re enter second
subject marks\n"); scanf("%f",&b); } printf("Enter your third
subject marks\n"); scanf("%f",&c); if(c>100) { printf("\nPlease Enter
number less than 100"); printf("\nPlease re enter
third subject marks\n"); scanf("%f",&c); } printf("Enter your fourth
subject marks\n"); scanf("%f",&d); if(d>100) { printf("\nPlease Enter
number less than 100"); printf("\nPlease re enter
fourth subject marks\n"); scanf("%f",&d); } printf("Enter your fifth
subject marks\n"); scanf("%f",&e); if(e>100) { printf("\nPlease Enter
number less than 100"); printf("\nPlease re enter fifth
subject marks\n"); scanf("%f",&e); } res=((a+b+c+d+e)*100)/500; if(res>=80){ printf("A+
grade\nand the percentage is %.2f ",res); } else if(res>=70){ printf("A
grade \n The percentage is %.2f",res); } else if(res>=60){ printf("B
grade \n The percentage is %.2f",res); } else if(res>=50){ printf("C
grade \n The percentage is %.2f",res); } else { printf("fail"); } //printf("%f",res); return
0; }