A program to enter marks of 3 subjects of a student and calculate the total marks, average & the grade obtained by him, using a function 'display'.

 

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

char name;
int a,b,c,total,avg,grade;

void display();

void main()
{
clrscr();
cout<<"Enter marks of first subject:";
cin>>a;
cout<<"Enter marks of second subject:";
cin>>b;
cout<<"Enter marks of third subject:";
cin>>c;
display();
}

void display()
{
total=a+b+c;
cout<<"The total marks are:"<<total<<"\n";
avg=total/3;
cout<<"The average marks are:"<<avg<<"\n";
if(avg>90)
 cout<<"Grade: A+";
else
 if(avg>75)
  cout<<"Grade: A";
 else
  if(avg>60)
   cout<<"Grade: B";
  else
   if(avg>45)
    cout<<"Grade: C";
  else
   if(avg>33)
    cout<<"Grade: D";
  else
   if(avg>32)
    cout<<"Grade: E";
getch();
}

 

< Back