This program code determines the grade of a student based on the following grade sheet. We have used an if else if statement to carry out the process.
Percentage | Grade |
---|---|
>90 | First Class with distinction |
80-90 | First Class |
70-80 | Second Class |
60-70 | Third Class |
50-60 | Passed |
<50 | Failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int m1,m2,m3,total; | |
float p; | |
printf("Enter the 3 marks (out of 100): "); | |
scanf("%d%d%d",&m1,&m2,&m3); | |
total =m1+m2+m3; | |
p=(float)total/300; | |
p=p*100; | |
printf("Your Percentage is %f\n",p); | |
if(p>=90) | |
{ | |
printf(" You have First Class with Distinction"); | |
} | |
else if(90>p&&p>=80) | |
{ | |
printf("You have First Class"); | |
} | |
else if(80>p&&p>=70) | |
{ | |
printf("You have Second Class"); | |
} | |
else if(70>p&&p>=60) | |
{ | |
printf("You have Third Class"); | |
} | |
else if(60>p&&p>=50) | |
{ | |
printf("You have Passed"); | |
} | |
else | |
{ | |
printf("You have Failed"); | |
} | |
getch(); | |
return(0); | |
} |
Comments
Post a Comment