Marks of five subjects

SemiColon
By -
0 minute read
0
6. Write a C program to input marks of five subjects of a student and calculate total, average and percentage of all subjects. 

Example:

Input
Enter marks of five subjects: 95 76 85 90 89

Output
Total = 435
Average = 87
Percentage = 87.00

Solution:

#include<stdio.h>
int main ()
{
    double a,b,c,d,e,total,avg,per;

    printf("Enter marks of five subjects: ");
    scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&e);

    total = a+b+c+d+e;
    avg = total/5;
    per = (total * 100) / 500;             // Full Marks = '500'

    printf("Total = %.0lf\n",total);
    printf("Average = %.0lf\n",avg);
    printf("Percentage = %.2lf\n",per);

    return 0;


}



Tags:

Post a Comment

0Comments

Post a Comment (0)