ADVERTISEMENT
ADVERTISEMENT

C program to read the grade of student print equivalent description

Here, we are going to learn how to read the grade of student print equivalent description using C program?
Submitted by Nidhi, on August 27, 2021

Problem Solution:

Read the grade of the student from the user, and print an equivalent message.

Program:

The source code to read a grade of student print equivalent description is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.

// C program to read a grade of student and
// print equivalent description

#include <stdio.h>

int main()
{
    char grade = 0;

    printf("Enter Grade: ");
    scanf("%c", &grade);

    switch (grade) {
    case 'a':
    case 'A':
        printf("Excellent");
        break;

    case 'b':
    case 'B':
        printf("Very Good");
        break;

    case 'c':
    case 'C':
        printf("Good");
        break;

    case 'y':
    case 'Y':
        printf("You are absent");
        break;

    case 'f':
    case 'F':
        printf("You are failed");
        break;

    default:
        printf("Invalid grade");
        break;
    }

    return 0;
}

Output:

Enter Grade: A
Excellent

Explanation:

Here, we created a variable grade of character type, and read the value of the grade variable and print the appropriate message on the screen.

C Basic Programs »


ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.