find total, average and percentage

#include<stdio.h>
int main()
{
      int m1,m2,m3,m4,m5,total;
      float avg,per;
      scanf("%d%d%d%d%d", &m1,&m2,&m3,&m4,&m5);
      total=m1+m2+m3+m4+m5;
      avg=total/5;
      per=(total/500.0)*100;
     printf("Total marks = %d\n", total);
    printf("Average marks = %.2f\n", avg);
    printf("Percentage = %.2f", per);
       //%.2f is used to print fractional values only up to 2 decimal places. You can also use %f to print          //up to 6 decimal places by default.
    return 0;
}

Input:
50 60 75 98 45
Output:
Total marks = 328
Average marks = 65.00
Percentage = 65.60

No comments:

Post a Comment