//Add 5 subjects marks of students and calculate percentage.
#include<stdio.h>
#include<conio.h>
void main()
{
float sub1,sub2,sub3,sub4,sub5,percentage;
clrscr();
printf("Enter the first subject marks:");
scanf("%f",&sub1);
printf("Enter the second subject marks:");
scanf("%f",&sub2);
printf("Enter the third subject marks:");
scanf("%f",&sub3);
printf("Enter the fourth subject marks:");
scanf("%f",&sub4);
printf("Enter the fifth subject marks:");
scanf("%f",&sub5);
percentage=((sub1+sub2+sub3+sub4+sub5)*100)/500.0;
printf("percentage:%f",percentage);
getch();
}
Output:
Enter the first subject marks:56.0Enter the second subject marks:58.5
Enter the third subject marks:85.5
Enter the fourth subject marks:75.0
Enter the fifth subject marks:65.0
percentage:68.000000
No comments:
Post a Comment