STUDENT MARK DETAILS USING C++
PROGRAM:
#include<iostream.h>
#include<conio.h>
int sum(int,int,int);
void grade(int);
class stu
{
private:
int rno,m1,m2,m3,tot,avg;
char name[50];
public:
void getdata();
void putdata();
};
void main()
{
class stu s[50];
int i,n;
clrscr();
cout<<"\n\t STUDENT MARK DETAILS USING FUNCTION TYPES";
cout<<"\n\t ************************************************";
cout<<"\n Enter the no of students:";
cin>>n;
for(i=1;i<=n;i++)
s[i].getdata();
cout<<"\n\t ANNA UNIVERSITY COIMBATORE ";
cout<<"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
cout<<"\n RNO \t NAME \t MARK1 \t MARK2 \t MARK3 \t TOTAL \t AVG \t GRADE \n ";
for(i=1;i<=n;i++)
s[i].putdata();
cout<<"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
getch();
}
void stu::getdata()
{
cout<<"\n Enter Rno:";
cin>>rno;
cout<<"\n Enter Name:";
cin>>name;
cout<<"\n Enter three subject marks:";
cin>>m1>>m2>>m3;
tot=sum(m1,m2,m3);
avg=tot/3;
}
void stu::putdata()
{
cout<<"\n"<<rno<<"\t"<<name<<"\t"<<m1<<"\t"<<m2<<"\t"<<m3<<"\t"<<tot<<"\t"<<avg;
grade(avg);
}
int sum(int a,int b,int c)
{
int tot;
tot=a+b+c;
return(tot);
}
void grade(int a)
{
if(a<50)
cout<<"\t FAIL";
else if(a>=50&&a<60)
cout<<"\t B GRADE";
else
cout<<"\t A GRADE";
}
OUTPUT:
STUDENT MARK DETAILS USING FUNCTION TYPES
************************************************
Enter the no of students:2
Enter Rno:101
Enter Name:VIVEK
Enter three subject marks:
70
75
78
Enter Rno:102
Enter Name:VINOTH
Enter three subject marks:
54
34
55
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RNO NAME MARK1 MARK2 MARK3 TOTAL AVG GRADE
101 VIVEK 70 75 78 223 74 A GRADE
102 VINOTH 54 34 55 143 47 FAIL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments
Post a Comment