Calculate the percentage in C by R4R Team

percent=(total marks)/ number of subjects

program-

#include< stdio.h>
int main() {
int m1,m2,m3,m4,m5,total;
float percentage;
printf("Enter mark in Subject1\n");
scanf("%d",&m1);
printf("Enter mark in Subject2\n");
scanf("%d",&m2);
printf("Enter mark in Subject3\n");
scanf("%d",&m3);
printf("Enter mark in Subject4\n");
scanf("%d",&m4);
printf("Enter mark in Subject5\n");
scanf("%d",&m5);
total=m1+m2+m3+m4+m5;
percentage=total/5;
printf("Percentage is %f",percentage);
}


output-

Enter mark in subject1
90
Enter mark in subject2
40
Enter mark in subject3
70
Enter mark in subject4
80
Enter mark in subject5
100
Percentage is 76.000000

-In this program, we take an input of 5 subject marks and store in variable m1,m2,m3,m4,m5
-Then find total marks that store in varible 'total'
-then find percentage by formula and display that.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!