C Program to Calculate and Average Percentage Marks

« Previous Program Next Program »

Calculate Average and Percentage Marks in C

To calculate average and percentage marks of a student in C programming, you have to ask to the user to enter marks obtained in some number of subjects (5 subjects here, i.e., Physics, Chemistry, Maths, CS, and English). Place summation of 5 subject's marks in a variable say sum and place sum/5 in a variable say avg then place sum/500*100 in a variable say perc, then display the result

C Programming Code to Calculate Average and Percentage Marks

Following C program ask the user to enter the marks obtained in 5 subjects to calculate and display the average and percentage marks :

/* C Program - Calculate Average and Percentage Marks */
void main()
	int mark[5], i;
	float sum=0;
	printf("Enter marks obtained in Physics, Chemistry, Maths, CS, English :");
	for(i=0; i<5; i++)
	float avg=sum/5;
	float perc;
	printf("Average Marks = %f",avg);
	printf("\nPercentage = %f%",perc);

When the above c program is compile and executed, it will produce the following result:

c program average percentage marks

Same Program in Other Programming Language

You may also like same program in other programming languages:

« Previous Program Next Program »


Quick Links
Signup - Login - Give Online Test