Write a C program that accepts the marks of 5 subjects and finds the sum and percentage marks obtained by the student:-
Here, we have to write a simple C program that takes marks obtained in different subjects by the user and gives total marks and percentage values as output.
Formula used:-
Percentage= (sum/500)*100
Explanation & Program code:-
We will ask the user to enter the marks of different subjects, then we will store the entered marks in the respective variables. Based on the entered marks of different subjects, we will calculate the total marks and percentage. Further details are mentioned as comments in the program code.
#include <stdio.h>
#include <math.h>
int main()
{
float maths,physics,chemistry,computer,mechanics,sum,per; /* Decleration of variable*/
printf("Enter marks obtained in Maths:-");
scanf("%f",&maths);
printf("Enter marks obtained in Physics:-");
scanf("%f",&physics);
printf("Enter marks obtained in Chemistry:-"); /* Taking input from user and storing it to respective variables*/
scanf("%f",&chemistry);
printf("Enter marks obtained in Computer:-");
scanf("%f",&computer);
printf("Enter marks obtained in Mechanics:-");
scanf("%f",&mechanics);
sum=maths+physics+chemistry+computer+mechanics; /* Calculation of total marks*/
printf("Total marks:-%.2f\n",sum);
per=(sum/500)*100; /* Percentage calculation*/
printf("Percentage:-%.2f",per); /*Calculated percentage as Output*/
return 0;
}
Output:-
Enter marks obtained in Maths:-89
Enter marks obtained in Physics:-86
Enter marks obtained in Chemistry:-56
Enter marks obtained in Computer:-89
Enter marks obtained in Mechanics:-97
Total marks:-417.00
Percentage:-83.40
Algorithm of program that accepts the marks of 5 subjects and finds the sum and percentage marks obtained by the student:-
Flowchart of the program that accepts the marks of 5 subjects and finds the sum and percentage marks obtained by the student:-

As you have reached the end of the article, so I hope as of now you have a clear understanding of the algorithm, flowchart, and program code that accepts the marks of 5 subjects and finds the sum and percentage marks obtained by the student. Please let me know your queries, suggestion, and feedback in the comment section.