Exercise 3:
If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and the percentage marks obtained by the student. Assume that the maximum marks obtained by a student in each subject is 100.
Solution:
The output of this program is as follows:
Enter the marks of five different subjects one by one: 81 75 60 92 52
Therefore the total marks of the student = 360
And the percentage of marks of that student = 72.0000 %
If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and the percentage marks obtained by the student. Assume that the maximum marks obtained by a student in each subject is 100.
Solution:
#include<stdio.h>In this program the marks of five different subjects are inputted from the user and then the calculation of the total or the aggregate is done and then the calculation of the percentage is done and then the result is displayed to the user.
#include<conio.h>
void main()
{
int m1, m2, m3, m4, m5, tot;
float perc;
printf(“Enter the marks of five different subjects one by one: ”);
scanf(“%d %d %d %d %d”, &m1, &m2, &m3, &m4, &m5);
tot=m1+m2+m3+m4+m5;
perc=(tot/500)*100;
printf(“\nTherefore the total marks of the student = %d \nAnd the percentage of marks of that student = %f %”, tot, perc);
getch();
}
The output of this program is as follows:
Enter the marks of five different subjects one by one: 81 75 60 92 52
Therefore the total marks of the student = 360
And the percentage of marks of that student = 72.0000 %
No comments:
Post a Comment
Please give your valuable comments or queries if you fell its helpful or if you like the contents of the site. Thanks...