#include <stdio.h>
int main(void){
int num; // Declare a variable to store the input
printf("Enter your mark "); // Prompt the user to enter their mark
scanf("%d", &num); // Read the user input
printf(" You entered %d \n", num); // Print the entered mark
if(num >= 80){
printf(" You got A grade"); // Check for A grade
}
else if (num >= 60){ // Check for B grade
printf(" You got B grade");
}
else if (num >= 40){ // Check for C grade
printf(" You got C grade");
}
else { // Check for failing condition
printf(" You Failed in this exam");
}
return 0; // End of program
}
#include <stdio.h>
int main(void){
int num; // Declare a variable to store the input
printf("Enter your mark "); // Prompt the user to enter their mark
scanf("%d", &num); // Read the user input
printf(" You entered %d", num); // Print the entered mark
if (num > 100) { // Check for invalid marks greater than 100
printf(" ! Wrong data ");
}
else if (num >= 80) { // Check for A grade
printf(" You got A grade");
}
else if (num >= 60) { // Check for B grade
printf(" You got B grade");
}
else if (num >= 40) { // Check for C grade
printf(" You got C grade");
}
else { // Check for failing condition
printf(" You Failed in this exam");
}
return 0; // End of program
}
#include <stdio.h>
void main() {
float m1, m2, m3; // Variables for marks
float per, avg; // Variables for percentage and average
float total; // Variable for total marks
printf(" enter the marks of m1 ");
scanf("%f", &m1); // Input for m1
printf(" enter the marks of m2 ");
scanf("%f", &m2); // Input for m2
printf("enter the marks of m3 ");
scanf("%f", &m3); // Input for m3
total = m1 + m2 + m3; // Calculate total marks
printf("\n the total mark is %.2f ", total); // Display total
per = (total / 300) * 100; // Calculate percentage
avg = (total / 3); // Calculate average
printf("\n the percentage mark is : %.2f ", per); // Display percentage
printf("\n the average mark is: %.2f", avg); // Display average
// 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 printf("\n Fail "); // Grade calculation based on percentage
printf("\n Press Enter to exit...");
getchar(); // Wait for user input before exiting
}
To calculate grades for multiple students, you can use arrays to store their marks and loop through them:
#include <stdio.h>
int main() {
int marks[5] = {85, 92, 75, 60, 45}; // Array of student marks
char grade; // Variable to store the grade
for (int i = 0; i < 5; i++) { // Loop through each student
if (marks[i] >= 90) { // Grade A for marks 90 or above
grade = 'A';
} else if (marks[i] >= 80) { // Grade B for marks 80-89
grade = 'B';
} else if (marks[i] >= 70) { // Grade C for marks 70-79
grade = 'C';
} else if (marks[i] >= 60) { // Grade D for marks 60-69
grade = 'D';
} else { // Grade F for marks below 60
grade = 'F';
}
printf("Student %d: Marks = %d, Grade = %c\n", i + 1, marks[i], grade); // Display student info
}
return 0; // Exit the program
}
This example calculates the average marks and assigns a grade based on the overall class performance:
#include <stdio.h>
int main() {
int marks[5] = {85, 92, 75, 60, 45}; // Array of student marks
int total = 0; // Variable to store the total marks
float average; // Variable to store the class average
char grade; // Variable to store the class grade
for (int i = 0; i < 5; i++) { // Loop through the marks array
total += marks[i]; // Add each student's marks to the total
}
average = total / 5.0; // Calculate the class average
// Assign the grade based on the average
if (average >= 90) {
grade = 'A';
} else if (average >= 80) {
grade = 'B';
} else if (average >= 70) {
grade = 'C';
} else if (average >= 60) {
grade = 'D';
} else {
grade = 'F';
}
printf("Class Average = %.2f, Grade = %c\n", average, grade); // Print the results
return 0; // End of the program
}
Here’s how to handle invalid input where marks might be out of the valid range (0-100):
#include <stdio.h>
int main() {
int mark; // Variable to store the student's mark
printf("Enter student's mark (0-100): "); // Prompt user for input
scanf("%d", &mark); // Read the input
if (mark < 0 || mark > 100) { // Validate input range
printf("Invalid input. Please enter a value between 0 and 100.\\n");
} else if (mark >= 90) { // Grade A for marks 90 and above
printf("Grade: A\n");
} else if (mark >= 80) { // Grade B for marks 80-89
printf("Grade: B\n");
} else if (mark >= 70) { // Grade C for marks 70-79
printf("Grade: C\n");
} else if (mark >= 60) { // Grade D for marks 60-69
printf("Grade: D\n");
} else { // Grade F for marks below 60
printf("Grade: F\n");
}
return 0; // End of the program
}
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 |
22-02-2021 | |
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. |
09-03-2021 | |
it was goooooood thank u |
26-03-2021 | |
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 |
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 |
20-03-2022 | |
Thanks for your explanation now I understand |
22-06-2022 | |
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 |
27-06-2022 | |
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 |
23-07-2022 | |
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.. |
27-08-2022 | |
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 |
01-10-2022 | |
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" 0-29 E.fail 30-39 D.refer 40-49 C.pass 50-58 B.Credit 69-100 A.distinction |
08-10-2022 | |
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 |
07-11-2022 | |
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 |
11-12-2022 | |
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. |
02-06-2023 | |
program that shows name, subject, subject grades, final grades |
11-02-2024 | |
Write a visual basic program that would accept the marks through a text box and display the marks on the message box use an if statement. Marks. Remarks Below 40. Fail 41 to 60. Pass 61 to 70. Credit 71 to 100. Distinctions |