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 ");
scanf("%d",&num);
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 ");
scanf("%d",&num);
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
#include<stdio.h>
#include<conio.h>

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 ");

	getch();
}
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

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    sam

    25-10-2013

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

    25-10-2013

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

    14-01-2014

    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)
    {
    output=4;

    }

    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;

    }

    else
    { output= 0.0;}

    return output;

    }

    int main ()

    {
    a:
    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

    17-03-2015

    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"
    tom

    14-08-2015

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

    05-10-2015

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

    11-10-2015

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

    17-10-2015

    how calculated CGP using loop statement
    Gayathri

    18-01-2016

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

    04-02-2016

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


    mary sunasr

    08-05-2016

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

    27-05-2016

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

    28-06-2016

    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

    01-07-2016

    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

    04-08-2016

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

    18-10-2016


    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

    09-11-2016

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

    23-11-2016

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

    26-11-2016

    good work
    dickson

    12-01-2017

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

    23-02-2017

    how to do this by using functions?
    gotlieb

    14-04-2017

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

    01-08-2017

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

    05-09-2017

    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.
    Rahma

    09-11-2017

    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

    09-11-2017

    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

    tesfahun

    21-12-2017

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

    30-07-2018

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

    02-08-2018

    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.
    cyra

    08-08-2018

    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%
    prelim-20%
    midterm-25%
    final-35%..

    maya

    06-09-2018

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

    15-09-2018

    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)??????
    Bob

    27-09-2018

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

    30-09-2018

    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

    05-10-2018

    write a program to find grades of five subjects
    kyle william

    20-10-2018

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

    21-11-2018

    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

    30-11-2018

    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

    22-01-2019

    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

    25-03-2019

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

    03-06-2019

    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

    27-06-2019

    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;
    }

    06-07-2019

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

    28-07-2019

    Why does doing flow charts of students grade?

    30-08-2019

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

    Result>=90=A+
    Result>=80=A
    Result>=70=B
    Result>=60=C
    Result>=50=D
    else F

    04-10-2019

    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?

    19-12-2020

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

    28-12-2020

    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

    04-12-2021

    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):

    09-02-2022

    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

    13-03-2022

    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]

    20-03-2022

    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 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer