C Program To Calculate Percentage of 5 Subjects

PROGRAM :

#include<stdio.h>
int main()
{
    int a,b,c,d,e,sum,t;
    float per,per1;
    printf("Enter the marks of 5 subject \n");
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    printf("\nEnter the Total Marks\n");
    scanf("%d",&t);
    sum = a+b+c+d+e;
    per = sum*100;
    per1 = per/t;
    printf("\nMarks Obtained = %d / %d\n",sum,t);
    printf("\nPercentage = %.2f",per1);  
}




OUTPUT :

Enter the marks of 5 subject
90
80
95
97
96
Enter the Total Marks
500
Marks Obtained = 458 / 500
Percentage = 91.60

Post a Comment

0 Comments