C++ Program to Calculate Grade of Student

Google Advertisements

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

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. If you want to post your article on our website/FB Group/FB Page please contact on [email protected] or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: [email protected] or 8076671483

Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders.

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar.

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user.

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects.

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: [email protected] or 8076671483