C++ Program to Calculate Grade of Student


Prev Tutorial Next Tutorial

C++ Program to Calculate Grade of Student

Here we write a C++ program to find grade of student, If percentage is greater than 85% print A grade, If percentage is less than 85% print B grade, If percentage is less than 75 print C grade, If percentage is less than 50 print D grade, If percentage is less than 30 print fail."

Algorithm to Calculate Grade of Student

  • 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).
  • If percentage > 85 print A grade, If percentage < 85 && percentage >= 75 print B grade, If percentage < 75 && percentage >= 50 print C grade, If percentage > 30 && percentage <= 50 print D grade, If percentage <30 print fail
  • Finally print percentage on screen.

C++ Program to Calculate Grade of Student Using if else

#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<<" subject: ";
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<<" %" <<endl;
if(per>85) {
cout<<"A grade";
}
else if(per<85 && per>=75) 
{
cout<<"B grade";
}
else if(per<75 && per>=50)
{
cout<<"C grade";
}
else if(per<50 && per>=30) 
{
cout<<"D grade";
}
else 
{
cout<<"Fail";
}
getch();
}

Output 1

Enter number of subject: 6
Enter marks of 6 subject: 
88
67
98
76
63
72
Percentage: 77.33 %
B grade

Output 2

Enter number of subject: 5
Enter marks of 5 subject: 
77
87
95
83
92
Percentage: 86.80 %
A grade

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