C Program to find sum and percentage of subjects
Program
#include<stdio.h>
void main()
{
int m1, m2, m3, m4, m5, total_marks;
int max_marks = 500;
float percent;
printf("Enter marks of 5 subjects\n");
printf("Subject 1:\t");
scanf("%d", &m1);
printf("Subject 2:\t");
scanf("%d", &m2);
printf("Subject 3:\t");
scanf("%d", &m3);
printf("Subject 4:\t");
scanf("%d", &m4);
printf("Subject 5:\t");
scanf("%d", &m5);
total_marks = m1 + m2 + m3 + m4 + m5;
printf("Total marks: %d\n", total_marks);
percent = (total_marks * 100) / max_marks;
printf("Percentage: %f\n", percent);
}
Output
Enter marks of 5 subjects
Subject 1: 72
Subject 2: 89
Subject 3: 93
Subject 4: 67
Subject 5: 79
Total marks: 400
Percentage: 80.000000