Home / Programs / Program to calculate sum of 5 subjects and find percentage
Programming Example

Program to calculate sum of 5 subjects and find percentage

👁 1,472 Views
💻 Practical Program
📘 Step by Step Learning
Program to calculate sum of 5 subjects and find percentage

Program Code

/* Documentation Section
Program to calculate sum of 5 subjects and find percentage.
author: atnyla developer
*/

#include<stdio.h>
#include<conio.h>
void main()
{
	int s1,s2,s3,s4,s5,sum,total=500;
	float per; 
	printf("enter marks of 5 subjects: \n");
	scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
	sum=s1+s2+s3+s4+s5;
	printf("sum=%d",sum);
	per=(sum*100)/total;
	printf("percentage=%f \n",per); 
}

Output

 

Explanation

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.