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 display the corresponding college level of a given input year level. The year and the college levels are given below: Year Level College Level 1 Freshmen 2 Sophomore 3 Junior 4 Senior Other years Unlisted Level.


    it was goooooood thank u


    11. Write a C program to enter the student five subject marks, computes the total, the average, and output the respective grade. The following should be put in consideration. Grading should be as follows
    70 - 100: A
    60 - 69: B
    50 - 59: C
    40 - 49: D
    39 and below fail


    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


    Thanks for your explanation now I understand


    Write a python program to grade any score entered from the keyboard as either “Poor” for a score that is below 50% or “Satisfactory” for a score that is equal to or above 50%. The program execution should stop as soon as a score that is less than zero is entered


    Create a program that will accept input from the user. The teacher will have to input 4 marks for a student (using for loop). Then program will execute a function that will find the average of the 4 marks. Using the average mark, the program will then execute another function that will find the grade the student will get with that average marks referring to Grade table.

    Marks Grade
    85 - 100 A
    70 – 84 B
    60 - 69 C
    50 - 59 D
    40 - 49 E
    1 - 39 F


    My problem is..What if he is failed in one subject but got higher marks in other subjects.. the percentage will be high..He is Failed in grade but the percentage is High..So he got a GOOD GRADE..I need a program..if one subject fail..Grade is also fail..


    9. Develop an algorithm that accepts your mark out of 100 for Computer Programming course and prints its corresponding letter grade based on the scale indicated below.
    Mark Letter grade
    0<=mark<40 F
    40<=mark<50 D
    50<=mark<60 C 10
    60<=mark<75 B
    75<=mark<=100 A


    Program with exam score as an integer in the range 0-100.The program displays the grade"using following ranges otherwise it output error"wrong marks"
    30-39 D.refer
    40-49 C.pass
    50-58 B.Credit
    69-100 A.distinction


    Write a program that accepts marks input of students and output a grade for the respective mark!!!
    100 - 70 A
    69 - 60 B
    59 - 50 C
    49 - 40 D
    39 and below F


    Write a C++ program to determine the grade of a student in a course given his/her score using if, else-if and else statements. (70-100=A, 60-69=B, 50-59=C, 40-49=D, <40=F)
    Modify the program in (2) to print the full meaning of each grade point using switch statement as follows (A=Excellent, B=Very good, C=Good, D=Pass and F= Fail)
    Convert the program in (3) to use enums instead of character literals


    Analyze the below scenario and develop a c program by taking proper
    inputs. Calculate the average marks for a student. The class has four quizzes
    (20% weightage), two mid-terms (20% weightage), and a final exam (60%
    weightage). The maximum marks for each quiz and exam (mid or final exam)
    is 100 marks.


    program that shows name, subject, subject grades, final grades

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer