How to give grade on number in C

#include
#include

/* run this program using the console pauser or add your own getch, system(“pause”) or input loop */

int main(int argc, char *argv[]) {
int sub1,sub2,sub3,sub4,sub5;
double percentage,obtmarks;
printf(“Enter your marks =”);
scanf(“%d”,&sub1);
printf(“Enter your marks =”);
scanf(“%d”,&sub2);
printf(“Enter your marks =”);
scanf(“%d”,&sub3);
printf(“Enter your marks =”);
scanf(“%d”,&sub4);
printf(“Enter your marks =”);
scanf(“%d”,&sub5);

obtmarks=sub1+sub2+sub3+sub4+sub5;
printf(“Your Obtained marks =%3.1f\n”,obtmarks);
percentage=obtmarks/500*100;
printf(“Your percentage is =%3.2f\n”,percentage);

if(percentage>85 && percentage<=100){ printf("Your grade is = A+"); } else if(percentage>75 && percentage<=85){ printf("Your grade is = A"); } else if(percentage>65 && percentage<=75){ printf("Your grade is = B"); } else if(percentage>55 && percentage<=65){ printf("Your grade is = C"); } else if(percentage>45 && percentage<=55){ printf("Your grade is = D"); } else if(percentage>33 && percentage<=45){ printf("Your grade is = E"); } else{ printf("You are Fail"); } return 0; }

Leave a Reply

Your email address will not be published. Required fields are marked *