C Program to calculate sum of 5 subjects and find percentage

C Program to calculate sum of 5 subjects and find percentage:
If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().

#include<stdio.h>

main()
{
   int m1,m2,m3,m4,m5,sum,total=500;
   float per;

   printf("Enter marks of 5 subjects : \n");
   scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);

   sum=m1+m2+m3+m4+m5;
   printf("Sum: %d\n",sum);

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

OUTPUT:

Enter marks of 5 subjects :
45
75
63
41
82
Sum: 306
Percentage: 61.000000

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.