C Program to Read a Grade & Display the Equivalent Descriptio

C Program to Read a Grade & Display the Equivalent Descriptio


This C Program reads grade & displays the equivalent description. If
 grade is S, it prints super, if grade is A, it prints very good, if 
grade is B, it prints fair, if grade is Y, it prints absent, if grade is
 F, it prints 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);
}

 

Comments

Popular posts from this blog

JavaScript

Invoke function without main in C Language

C Program to Display the IP Address of the System