Get Student Marks and Calculate Percentage & Division
Q. The marks obtained by a student in 5 different subjects are input through the keyboard.
The student gets a division as per the following rules:
Percentage above or equal to 60- 1st division
Percentage between 50 and 59- 2nd division
Percentage between 40 and 49- 3rd division
Percentage less then 40- Fail
Write a C program to calculate the division obtained by the student.
Ans.
/*c program for read 5 subject marks and calculate percentage & division of student*/
/*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;
}
The output of above program would be:
The student gets a division as per the following rules:
Percentage above or equal to 60- 1st division
Percentage between 50 and 59- 2nd division
Percentage between 40 and 49- 3rd division
Percentage less then 40- Fail
Write a C program to calculate the division obtained by the student.
Ans.
/*c program for read 5 subject marks and calculate percentage & division of student*/
/*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;
}
The output of above program would be:
Figure: Screen shot for read student marks and calculate percentage and find division C program |
No comments:
Post a Comment