C Programs | IT Developer
IT Developer

C Programs



Share with a Friend

Decision Making Programs in C

Find the grade of a student (marks-based)

Introduction

Grading is a common operation in academic systems.
Based on a student’s marks, the program will assign a grade like:

Marks Range

Grade

90–100

A

80–89

B

70–79

C

60–69

D

50–59

E

Below 50

F (Fail)

This program uses if-else conditions to determine the grade.

 

C Program: Find the grade of a student (marks-based)

C

#include <stdio.h>

 

int main() {

    float marks;

 

    // Input student marks

    printf("Enter the marks (out of 100): ");

    scanf("%f", &marks);

 

    // Check grade based on marks

    if (marks >= 90 && marks <= 100) {

        printf("Grade: A\n");

    }

    else if (marks >= 80 && marks < 90) {

        printf("Grade: B\n");

    }

    else if (marks >= 70 && marks < 80) {

        printf("Grade: C\n");

    }

    else if (marks >= 60 && marks < 70) {

        printf("Grade: D\n");

    }

    else if (marks >= 50 && marks < 60) {

        printf("Grade: E\n");

    }

    else if (marks >= 0 && marks < 50) {

        printf("Grade: F (Fail)\n");

    }

    else {

        printf("Invalid Marks! Please enter between 0 and 100.\n");

    }

 

    return 0;

}

Output

 
OUTPUT :
Enter the marks (out of 100): 95
Grade: A

Enter the marks (out of 100): 72
Grade: C

Enter the marks (out of 100): 45
Grade: F (Fail)