C++ Program to Calculate Percentage of Marks


Prev Tutorial Next Tutorial

Calculate Percentage of Student Marks Program in C++

Welcome once again on sitesbay, today we discuss about how to write code for 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 of Students Marks

  • First Receive Student 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.

C++ Program to Calculate Percentage of Student Marks

#include<iostream.h>
#include<conio.h>

void main()
{
int no, i;
float marks[10], per=0, total=0;
clrscr();
cout<<"Enter number of subject: ";
cin>>no;
cout<<"Enter marks of "<<no<<" subjects";
for(i=0; i<no; i++)
{
cin>>marks[i];
}
for(i=0; i<no; i++)
{
total=total+marks[i];
}
per=total/no;
cout<<"Percentage: "<<per;
getch();
}

Output 1

Enter number of subject: 4
Enter marks of 4 subject: 
80
93
87
95
Percentage: 88.75 %

Output 2

Enter number of subject: 5
Enter marks of 5 subject: 
83
86
94
73
92
Percentage: 85.6 %

Prev Tutorial Next Tutorial

Google Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements