codescracker


c

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 */

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int mark[5], i;
float sum=0;
printf("Enter marks obtained in Physics, Chemistry, Maths, CS, English :");
for(i=0; i<5; i++)
{
scanf("%d",&mark[i]);
sum=sum+mark[i];
}
float avg=sum/5;
float perc;
perc=(sum/500)*100;
printf("Average Marks = %f",avg);
printf("\nPercentage = %f%",perc);
getch();
}

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 »


Latest 5 Posts by CodesCracker




Tools
Calculator

Quick Links
Signup - Login - Give Online Test