programming-examples/c/_Basic/C Program to Read a Grade & Display the Equivalent Description.c

43 lines
1.0 KiB
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C Program to accept a grade and declare the equivalent description
* if code is S, then print SUPER
* if code is A, then print VERY GOOD
* if code is B, then print FAIR
* if code is Y, then print ABSENT
* if code is F, then print FAILS
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
void main()
{
char remark[15];
char grade;
printf("Enter the grade \n");
scanf("%c", &grade);
/* lower case letter to upper case */
grade = toupper(grade);
switch(grade)
{
case 'S':
strcpy(remark, " SUPER");
break;
case 'A':
strcpy(remark, " VERY GOOD");
break;
case 'B':
strcpy(remark, " FAIR");
break;
case 'Y':
strcpy(remark, " ABSENT");
break;
case 'F':
strcpy(remark, " FAILS");
break;
default :
strcpy(remark, "ERROR IN GRADE \n");
break;
}
printf("RESULT : %s\n", remark);
}