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 if else condition checking. Each if else condition check for mark for a particular grade and if it is TRUE then all other checking ( if else ) are omitted. 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;
}

Number of User Comments : 22

Seth

17-02-2013

Please help_What if the students score marks more 100 but less than or equal to 150 and you must divide the mark by 150multiplyby100 before getting the mark to grade and using only the #include library.
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;

}
mosses

07-04-2014

how could i write the same program by using c++ with switch statement
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
Nasozi mary

09-12-2015

Can i liz get the output of the previous code?
Gayathri

18-01-2016

How do we calculate total marks ,average, we put the grade??
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

Post Comment This is for short comments only. Use the forum for more discussions.




Subscribe to our mailing list

* indicates required
Subscribe to plus2net
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2017 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer