Monday, October 2, 2023
HomeCodesWrite a program to provide appropriate feedback to a student based on...

Write a program to provide appropriate feedback to a student based on grade secured in the exam

-

5/5 - (3 votes)

Write a program to provide appropriate feedback to a student based on grade secured in the exam. Consider the following while writing the program:

  • The possible grades are A, B, C, D, E, and F.
  • Provide the following feedback corresponding to the grade as follows:
    • A: Excellent! Keep it up.
    • B: Very good! Keep it up.
    • C: Good! Try improving in the next exam.
    • D: Average! Need to work hard.
    • E: Poor! Need a lot of hard work.
    • F: Failed! You need to attend special classes after school.
  • Allow users to input grade.
  • Consider how your program should behave if the user enters an invalid grade.
  • Use the switch case statement.
#include <stdio.h>


int main() {

    // WAP to provide appropriate feedback to a student based on grade secured in the exam.
    // Code challenge solution

    char grade;
    puts("Please enter grade: ");
    scanf("%c", &grade);

    switch (grade) {
        case 'A':
            puts("Excellent! Keep it up.");
            break;
        case 'B':
            puts("Very good! Keep it up.");
            break;
        case 'C':
            puts("Good! Try improving in the next exam.");
            break;
        case 'D':
            puts("Average! Need to work hard.");
            break;
        case 'E':
            puts("Poor! Need a lot of hard work.");
            break;
        case 'F':
            puts("Failed! You need to attend special classes after school.");
            break;
        default:
            puts("Invalid grade.");
    }

    return 0;
}

Related articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

0FansLike
0FollowersFollow
3,877FollowersFollow
0SubscribersSubscribe
spot_img

Latest posts