How to calculate sum of 5 subjects and find percentage Using C Program

C Program to calculate sum of 5 subjects and find percentage


#include <stdio.h>

int main() {
   int s1, s2, s3, s4, s5, sum, total = 500;
   float per;

   printf("\nEnter marks of 5 subjects : ");
   scanf("%d %d %d %d %d", &s1, &s2, &s3, &s4, &s5);

   sum = s1 + s2 + s3 + s4 + s5;
   printf("\nSum : %d", sum);

   per = (sum * 100) / total;
   printf("\nPercentage : %f", per);

   return (0);
}

Output :


Enter marks of 5 subjects : 80 70 90 80 80
Sum : 400
Percentage : 80.00
How to calculate sum of 5 subjects and find percentage Using C Program

Published on 16-Dec-2021 16:02:43

You may also like this!