/*we assume total marks is 500*/
#include<stdio.h>
int main()
{
float m1,m2,m3,m4,m5,avg,per; //m=marks
printf("Enter 5 subject marks: ");
scanf("%f %f %f %f %f",&m1,&m2,&m3,&m4,&m5);
per = (m1+m2+m3+m4+m5)*100/500;
printf("Student get %0.2f percentage. n",per);
if(per>=60)
printf("1st Division");
else if(per>=50 && per<=59)
printf("2nd Division");
else if(per>=40 && per<=49)
printf("3rd Division");
else if(per<40)
printf("Fail");
return 0;
}
#include <stdio.h>
int main(){
float m1,m2,m3,m4,m5,per;
printf("Enter 5 subject marks (0-100): ");
if(scanf("%f %f %f %f %f", &m1, &m2, &m3, &m4, &m5) != 5 ||
m1 < 0 || m1 > 100 || m2 < 0 || m2 > 100 ||
m3 < 0 || m3 > 100 || m4 < 0 || m4 > 100 ||
m5 < 0 || m5 > 100) {
printf("Invalid input. Please enter marks between 0 and 100.\n");
} else {
per = (m1 + m2 + m3 + m4 + m5) * 100 / 500;
printf("Student got %.2f%%\n", per);
}
return 0;
}
Output:
Enter 5 subject marks (0-100): 45 67 102 76 88
Invalid input. Please enter marks between 0 and 100.
#include <stdio.h>
int main(){
float m1, m2, m3, m4, m5, per;
printf("Enter 5 subject marks: ");
scanf("%f %f %f %f %f", &m1, &m2, &m3, &m4, &m5);
per = (m1 + m2 + m3 + m4 + m5) * 100 / 500;
printf("Percentage: %.2f%%\n", per);
if (per >= 75) {
printf("Distinction\n");
} else if (per >= 60) {
printf("1st Division\n");
} else if (per >= 50) {
printf("2nd Division\n");
} else if (per >= 40) {
printf("3rd Division\n");
} else {
printf("Fail\n");
}
return 0;
}
Output:
Enter 5 subject marks: 85 90 88 92 80
Percentage: 87.00%
Distinction
#include <stdio.h>
float calculate_percentage(float m1, float m2, float m3, float m4, float m5) {
return (m1 + m2 + m3 + m4 + m5) * 100 / 500;
}
void assign_division(float per) {
if (per >= 75) {
printf("Distinction\n");
} else if (per >= 60) {
printf("1st Division\n");
} else if (per >= 50) {
printf("2nd Division\n");
} else if (per >= 40) {
printf("3rd Division\n");
} else {
printf("Fail\n");
}
}
int main(){
float m1, m2, m3, m4, m5, per;
printf("Enter 5 subject marks: ");
scanf("%f %f %f %f %f", &m1, &m2, &m3, &m4, &m5);
per = calculate_percentage(m1, m2, m3, m4, m5);
printf("Percentage: %.2f%%\n", per);
assign_division(per);
return 0;
}
Output:
Enter 5 subject marks: 65 70 75 80 85
Percentage: 75.00%
Distinction
sadiya ramesh | 13-07-2014 |
help me out with this please Write a C program that prompts for students’ final grades in 5 units in a given class (the grades are integer values in the range 0-100). The program then displays the class grade average, the highest grade, and how many students in the class failed the course (a grade less than 40 is a failing grade). If a student fails in more than 2 subjects then a message “DISCONTINUATION” is displayed at the very end. |