Created
February 12, 2019 02:54
-
-
Save Rajssss/a0a0deeb4763ad06e1592e906ea5b924 to your computer and use it in GitHub Desktop.
grade.c
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() | |
| { | |
| float phy,chem,math,a; | |
| char c,g; | |
| printf("\nEnter choice \n\t1.If_Else\n\t2.Switch_case\n\t=>"); | |
| scanf("%c",&c); | |
| printf("\nEnter markes obtained in phy,chem and maths resp. =>"); | |
| scanf("%f %f %f",&phy,&chem,&math); | |
| a=(phy+chem+math)/3; | |
| if(c=='1') | |
| { | |
| if(a>=85) | |
| { | |
| g='A'; | |
| } | |
| else if((a<85)&&(a>=70)) | |
| { | |
| g='B'; | |
| } | |
| else if((a<70)&&(a>=50)) | |
| { | |
| g='C'; | |
| } | |
| else | |
| { | |
| g='F(Fail!)'; | |
| } | |
| } | |
| else | |
| { | |
| int x; | |
| x=a/10; | |
| switch (x) | |
| { | |
| case 8 ... 10: g='A';break; | |
| case 6 ... 7: g='B';break; | |
| case 4 ... 5: g='C';break; | |
| default: g='F'; | |
| } | |
| } | |
| printf("\n\tGrade=%c\n",g); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment