C Program to Calculate Percentage of Marks


Prev Tutorial Next Tutorial

Calculate Percentage of Marks Program in C

For calculate percentage of marks obtained by student, divide total marks by number of subject ( percentage=total marks / number of subject ).

Algorithm to calculate percentage

  • First received marks of each subject.
  • Calculate sum of all subjects marks.
  • divide total marks by number of subject (percentage=total marks / number of subject).
  • Finally print percentage on screen.

Program to calculate percentage of marks

#include<stdio.h>
#include<conio.h>

void main()
{
int no, i;
float marks[10], per=0, total=0;
clrscr();
printf("Enter number of subject: ");
scanf("%d",&no);
printf("Enter marks of %d subject: ",no);
for(i=0; i<no; i++)
{
scanf("%f",&marks[i]);
}
for(i=0; i<no; i++)
{
total=total+marks[i];
}
per=total/no;
printf("Percentage: %f %",per);
getch();
}

Output

Enter number of subject: 5
Enter marks of 5 subject: 
90
50
70
60
80
Percentage: 70.00 %

Prev Tutorial Next Tutorial

Advertisements




Download Projects

Advertisements

FREE Online Google Play APK Downloader

Buy APP Installs, Buy 100% Genuine Installs