Program to calculate grade of the student.

Calculate Grade of Student in C++

To calculate grade of a student on the basis of his total marks in C++ Programming, you have to ask to the user to enter marks obtained in some subjects (5 subjects here). To calculate grade of student, first calculate the mark's sum of all the subjects and then calculate average marks. Now start checking for the grades to display the result as shown here in the following program.

/* C++ Program - Calculate Grade of Student */
  
#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int mark[5], i;
 float sum=0,avg;
 cout<<"Enter marks obtained in 5 subjects :";
 for(i=0; i<5; i++)
 {
  cin>>mark[i];
  sum=sum+mark[i];
 }
 avg=sum/5;
 cout<<"Your Grade is ";
 if(avg>80)
 {
  cout<<"A";
 }
 else if(avg>60 && avg<=80)
 {
  cout<<"B";
 }
 else if(avg>40 && avg<=60)
 {
  cout<<"C";
 }
 else
 {
  cout<<"D";
 }
 getch();
}
Output:-

Post a Comment

0 Comments