C++ | Grade system for marks

Introduction

This is post that introduces to make a c++ program for grade system. The first one just calculates only percentage. The next shows the grade after inputing marks of subject. The next one shows message. You can extend the program by taking more subjects and showing grade. Go enjoy the program. Lets begin………..

Program for calculation of percentage

#include<iostream.h>
#include<conio.h>
void main()
{
//clear the screen.
clrscr();
//declare variables type int
int a,b,c;
//declare percentage variable type float
float per;
//Input the marks save them in variables
cout<<"Enter the marks of physics"<<endl;
cin>>a;
cout<<"Enter the marks of chemistry"<<endl;
cin>>b;
cout<<"Enter the marks of maths"<<endl;
cin>>c;
//calculate percentage and save them variable
per=(a+b+c)/3;
//cout percentage
cout<<"Percentage is "<<per;
//get character
getch();
}

Output

Enter the marks of physics
91
Enter the marks of chemistry
90
Enter the marks of maths
89
Percentage is 90

Program for grade system

#include<iostream.h>
#include<conio.h>
void main()
{
//clear the screen.
clrscr();
//declare variables type int
int a,b,c;
//declare percentage variable type float
float per;
//Input the marks save them in variables
cout<<"Enter the marks of physics"<<endl;
cin>>a;
cout<<"Enter the marks of chemistry"<<endl;
cin>>b;
cout<<"Enter the marks of maths"<<endl;
cin>>c;
//calculate percentage and save them variable
per=(a+b+c)/3;
//condition if-else statement
if(per>90)
cout<<"A grade";
else
{
if(per>80)
cout<<"B grade";
else
{
if(per>60)
cout<<"C grade";
else
{
if(per>35)
cout<<"D grade";
else
cout<<"E grade";
}
}
}
//get character
getch();
}

Output

Enter the marks of physics
91
Enter the marks of chemistry
90
Enter the marks of maths
89
B grade

Program for printing results

#include<iostream.h>
#include<conio.h>
void main()
{
//clear the screen.
clrscr();
//declare variables type int
int a,b,c;
//declare percentage variable type float
float per;
//Input the marks save them in variables
cout<<"Enter the marks of physics"<<endl;
cin>>a;
cout<<"Enter the marks of chemistry"<<endl;
cin>>b;
cout<<"Enter the marks of maths"<<endl;
cin>>c;
//calculate percentage and save them variable
per=(a+b+c)/3;
//condition if-else statement
if(per>90)
cout<<"Congratulations, you are in merit list";
else
{
if(per>80)
cout<<"Excellent, Keep it up";
else
{
if(per>60)
cout<<"Well done, Can improve more better";
else
{
if(per>35)
cout<<"Good, study more hardly next time";
else
cout<<"Failed, Give a re-test";
}
}
}
//get character
getch();
}

Output

Enter the marks of physics
91
Enter the marks of chemistry
90
Enter the marks of maths
89
Congratulations, you are in merit list

How does it work

  1. You enter the marks  in and is saved in variables.
  2. Calculates the percentage.
  3. Decides the grade according to if-else statement.
  4. Prints the grade or message.

Extending it

The program can be extended by using more subjects to find grade .You can take the input of subjects and print grade accordingly. You can even print the percentage in grade system along with message.

Explanation.

  1. Include ‘iostream.h’ and ‘conio.h’ files.
  2. Add void main.
  3. Start program by first clearing the screen.
  4. Declare the variables as int or float (name them as you want.)
  5. Add cout and cin of variable of input of subjects.(as shown in program)
  6. Calculate the percentage.
  7. Add the conditional statement if-else.
  8. Cout the grade.

At the end

You learnt creating the c++ program of finding a grade of marks. So now enjoy the program.

Please comment on the post and share it.
And like it if you liked.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s