Sunday, 15 December 2013

C Program to Read a Grade & Display the Equivalent Description

#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);
}

Output

 Enter the grade
s
RESULT  :  SUPER
   
Enter the grade
a
RESULT  :  VERY GOOD
   
Enter the grade
b
RESULT  :  FAIR
   
Enter the grade
y
RESULT  :  ABSENT
   
Enter the grade
f
RESULT  :  FAILS

For More Details Please Visit Ictjobs.info

No comments: