Skip to content

Instantly share code, notes, and snippets.

@Rajssss
Created February 12, 2019 02:54
Show Gist options
  • Save Rajssss/a0a0deeb4763ad06e1592e906ea5b924 to your computer and use it in GitHub Desktop.
Save Rajssss/a0a0deeb4763ad06e1592e906ea5b924 to your computer and use it in GitHub Desktop.
grade.c
#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