Grade of Mark in C program

We can enter mark to our c program and the script will try to find out the grade by using series of else if condition checking. Each if else condition check for mark for a particular grade and if it is TRUE then all other checking ( else if ) are omitted.
Getting the Grade by using input mark in C programming by using if else condition check

Here is the sample code.
#include <stdio.h>
int main(void){
int num;
printf("Enter your mark ");
printf(" You entered %d", num); // printing outputs

	if(num >= 80){
	printf(" You got A grade"); // printing outputs
	else if ( num >=60){ // Note the space between else & if
		printf(" You got B grade");
	else if ( num >=40){
		printf(" You got C grade");
	else if ( num < 40){
		printf(" You Failed in this exam");
return 0;

Not allowing mark above 100

#include <stdio.h>
int main(void){
int num;
printf("Enter your mark ");
printf(" You entered %d", num); // printing outputs
	if (num>100) printf(" ! Wrong data ");
	else if(num >= 80){
	printf(" You got A grade"); // printing outputs
	else if ( num >=60){ // Note the space between else & if
		printf(" You got B grade");
	else if ( num >=40){
		printf(" You got C grade");
	else if ( num < 40){
		printf(" You Failed in this exam");
return 0;

Calculating Percentage ,Average and Grade

Ask the user to enter marks in three subjects.
Find out the Percentage of mark and average mark in three subjects.
Based on the percentage of the student in three subjects , calculate the grade using this range.

80 or above A grade
60 or above B grade
40 or above C grade
39 or less Fail

void main ()
	float m1,m2,m3;
	float per,avg;
	float total;
	printf(" enter the marks of m1 ");
	scanf("%f", &m1);
	printf(" enter the marks of m2 ");
	scanf("%f", &m2);
	printf("enter the marks of m3 ");
	scanf("%f", &m3);
	total= m1+m2+m3;
	printf("\n the total mark is %.2f ",total);
	per = (total/300)*100;
	avg = (total/3);
	printf("\n the percentage mark is : %.2f ", per);
	printf("\n the average mark  is: %.2f", avg);
	///// Grade calculation //
	if(per>=80) printf("\n Grade : A");
	else if(per>=60) printf("\n Grade : B");
	else if(per>=40) printf("\n Grade : C");
	else if(per<40) printf("\n Fail ");

Allow user to enter numbers & exit if user enters 0 or negative number
if else Different tariff plan for different range of consumption (Example of if else )
Question answers on C –programming on calculation of Grade of the student based on the entered mark


* indicates required
Subscribe to plus2net



    what should i do to keep getting inputs to enter the marks multiple times till i manually exit from output screen.


    please can you show me the same program using switch statement
    suzon das


    Dear Sam,
    here is the code in total with sub function that let you to input multiple time with grading system. Please edit as your needs.

    # include <stdio.h>

    float verify (float a)

    float output;

    if (a>=80)


    else if (a>=75 && a<=79){

    output= 3.75;

    else if (a>=70 && a<=74){

    output= 3.5;

    else if (a>=65 && a<=69){

    output= 3.25;

    else if (a>=60 && a<=64){

    output= 3.0;

    else if (a>=55 && a<=59){

    output= 2.5;


    else if (a>=50 && a<=54){

    output= 2.0;

    else if (a>=40 && a<=49){

    output= 1.0;


    { output= 0.0;}

    return output;


    int main ()

    float number ;
    printf("Please Enter the course result marks: ");

    scanf("%f", &number);

    printf("The GPA is: %f", verify (number));

    return 0;
    goto a;

    Syed Bilal Azfar


    i want to ask if i put marks above 99 it show grade A+.. i want to check if i put above 99 if show message "error"


    thank you all for the good chat. you make my understanding of c fact,that was an assignment i was researching on!


    Can I have the output for the above program....


    Hello can you create an example of program that is conditional? Using c language?


    how calculated CGP using loop statement


    How do we calculate total marks ,average, we put the grade??


    Hi, can any one help me to write the same program by using switch statement .

    mary sunasr


    Plz show program to identify grades if u got x is greater than 8 .print grade A


    Asks the user to input marks of 6 subjects. The program should compute total marks, average, GPA and CGPA


    program that will accept 5 test marks, calculate the average mark and determine the grade for the student. You are to use the FOR LOOP and IF ELSE statements.
    simon muhiu


    Write a C program to compute the total marks scored by a student who sat for 8 Subjects in an exam. Include the code for awarding grades where (70%= First
    Class, 60% =Second Class, 50%=Pass, and below 50% =Fail)
    John Rey R. Lloren


    codes for c programming 5 students with average remark if passed or failed .


    10 students in a class
    Each student has taken five tests and each test is worth 100 points
    Your Data should consist of students’ names and their test scores

    Write a program:
    to calculate the average for each student as well as the class average
    to find the class average test score
    Bwire Eriya


    How can i get the program codes for getting technical failure for students???


    i would love to learn cprogramming ....pls where should i start from
    janet musyoka


    good work


    write down a c program that can display my name,course,department,level,date of birth,age and give aprintout?


    how to do this by using functions?


    help me with a program that read 8 subject and determine whether the student has pass or not


    how cod I write such program using Q.BASICS
    Gursharan Kaur


    Help me ..
    Write a program to receive marks of students in 3 tests display the %age, if the students scores 80% or more display special congratulating message also.


    Write a program that allow user to enter mark and display grade(70-100=A,60-69=B,50-59=C,40-49=D,below 40=fail)
    Kevine Nicky


    1. Write a C++ program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate the average and grade according to following: (10 marks)
    Percentage >= 90% : Grade A
    Percentage >= 80% : Grade B
    Percentage >= 70% : Grade C
    Percentage >= 60% : Grade D
    Percentage >= 40% : Grade E
    Percentage < 40% : Grade F
    a. Using if … else
    b. Using switch



    write a HTML program that display students grade in semster in one university calander
    sunday bitrus audu


    thanks a lot am great full for this wonderful answers
    Ghanashyam Koirala


    After deciding "Pass" or "Fail" using if-else if statement in C-programming., How to sore in a variable.
    Eg. if(eng>40 && math>40 && computer>40) result="Pass" else result="Fail". Is it possible in c programming like QBasic. Pl help.


    please help. thanks and GOD Bless..

    Make a program that will solve for the grades.
    -quizzes-> 50,30,20,20
    perfect score: 130
    ? M F
    exams-> 75,67,88
    perfect score: 100,100,100

    compute for the grades.
    quizzes- 20%



    Please give a student marks switch statment in c language
    Muhammad asad khan


    hello i am in serious trouble
    solve this problem if you can ( a class of 15 students take an examination in which marks range from 1-100.write a program to find and print the average marks)??????


    i appreciate for your assistance I'm now getting it well


    Write a C program to input result of 3 students from a subject and display:
    Name for each student
    Results for each student
    Sum of results for each student
    Average of results for all the students
    Average of results for all students
    Huzaifa hamid


    write a program to find grades of five subjects
    kyle william


    create a pseusocode that will display all numbers and students grades for example 70-100 display A
    Aqarib Daniyal


    Anyone else who help me
    I!m in confusion
    Write a program that inputs a character from user and determines whether that character is a digit, lowercase letter, uppercase letter, a
    whitespace character or any other special character. [Hint: use “char” data type to store character, refer to ASCII table]
    Q4: Write a program that inputs the marks of students in particular subject
    and determines the grade point and letter grade according to the following
    grading table:
    After finishing entering marks of students your program should also display
    the average marks, maximum marks, minimum marks and number of students
    having each of the following grades: A, B, C, D and F
    [Use sentinel-controlled iteration to enter marks of students, use counters for
    each grade]
    Dprince mvp


    Pls write a C code to read an integer value for score (0-100) and print the correct letter grade based on the following : below 50 should print F and 50-59 should print C,60-69 should print B, 70-79 should print B+, 80-89 should print A, then 90-100 should print A+.... Tnks pls I nid it in C program
    baba maliky


    kindly assist me write a c program to enter students name, scores in 3 subjects and then compute there grades according to total marks obtained
    Jididiya mandal


    Wright a program accept in 5 object total everege
    Great. Mark
    O. ≥80
    E ≥70
    B. ≥60
    C. ≥50
    D. ≥40
    F. ≥30


    Write a programme to input the marks of n students in a class and print the no of stidents getting 89, no of students getting 80 and 89 between 70 and 79 and others


    This is how I did it. I think, using AND logical operator may not be needed.
    #include <stdio.h>

    /* Display grades on the basis of average marks - C99 code */

    int main(void) {

    int avg;
    printf("Enter your average marks to determine grade:t");
    scanf("%d", &avg);

    if (avg >= 80 && avg <=100)
    printf("You are rewarded Honours graden");

    if (avg >= 60 && avg <= 79)
    printf("You are rewarded First Division as graden");

    if (avg >= 50 && avg <= 59)
    printf("You are rewarded Second Division as graden");


    if (avg >= 40 && avg <=49)
    printf("You are rewarded Third Division as graden");

    if (avg >=0 && avg <= 39)
    printf("You have failedn");

    else if (avg < 0 || avg > 100)
    printf("Wrong value entered, Please enter marks between 0 and 100n");

    return 0;


    thank,but how can i write a program to compute the final marks


    Why does doing flow charts of students grade?


    write a program that accept one fundamental of programming course result from the user on calculate the grade based on the following interval

    else F


    Write a program that promts the user to enter the number
    of students and each student's name and score,and finally display the student with the highest score?


    Write a program that inputs marks of two students and tells which student got the higher marks using conditional operator
    in c language


    A computer science instructor needs a program that averages the
    grades she receives on a quiz she gives to her class. Each grade is
    an integer between 0 and 100. She does not know the number of
    grade at this time. Write a program that asks the user to enter quiz
    grades one at a time. After the user has completed entering
    grades, the program should display the number of grades entered
    and the sum of the grades entered. The program should also
    display the average of the grades


    Create a program that will computes for the average of the student for (eng, math & science), remarks “Passed” or “Failed” then classify the equivalent average:
    98-100 -> Excellent
    94-97 -> Very Good
    90-93 -> Good
    85-89 -> Very Satisfactory
    80-84 -> Satisfactory
    75-79 -> Needs Improvement
    70-74 -> Poor

    Use the tools learned in problem definition and analysis (HIPO):


    write a program that input the marks of three subject from the user in the main function passes marks to function and find average . if avg is greater than 50 then display on screen message pass other wise fail=in C language... some body can reply me with its code


    Write a c program that gets marks for 10 students and computes the average and sum
    for the marks, it should also compute the frequency distribution of the marks e.g. 2
    students got 20%, 4 Students got 30 %. [20 Marks]


    Thanks for your explanation now I understand

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer