#include<iostream.h>
#include<conio.h>
#include<string.h>
class stu{
protected:
int roll;
char name[45],course[10];
public:
stu(int r, char n[], char c[])
{
roll=r;
strcpy(course,c);
strcpy(name,n);
}
};
class exam:public stu
{
protected:
int marks[3];
public:
exam(int r, char n[], char c[], int *m):stu(r,c,n)
{
marks[0]=*m;
marks[1]=*(m+1);
marks[2]=*(m+2);
}
};
class result:public exam
{
protected:
int total; float avg;
public:
result(int r, char n[], char c[], int *m):exam(r,c,n,m)
{
total=marks[0]+marks[1]+marks[2];
avg=total/3;
}
void display(void)
{
cout<<"\nName: "<<name<<"\nRoll: "<<roll<<"\nCourse: "<<course<<"\nMarks: "<<marks[0]<<' '<<marks[1]<<' '<<marks[2]<<"\nTotal= "<<total<<"\nAverage= "<<avg;
}
};
void main()
{
int m[]={100,98,99};
result ob1(03,"Rahul Kumar","B.C.A",m);
ob1.display();
getch();
clrscr();
}
#include<conio.h>
#include<string.h>
class stu{
protected:
int roll;
char name[45],course[10];
public:
stu(int r, char n[], char c[])
{
roll=r;
strcpy(course,c);
strcpy(name,n);
}
};
class exam:public stu
{
protected:
int marks[3];
public:
exam(int r, char n[], char c[], int *m):stu(r,c,n)
{
marks[0]=*m;
marks[1]=*(m+1);
marks[2]=*(m+2);
}
};
class result:public exam
{
protected:
int total; float avg;
public:
result(int r, char n[], char c[], int *m):exam(r,c,n,m)
{
total=marks[0]+marks[1]+marks[2];
avg=total/3;
}
void display(void)
{
cout<<"\nName: "<<name<<"\nRoll: "<<roll<<"\nCourse: "<<course<<"\nMarks: "<<marks[0]<<' '<<marks[1]<<' '<<marks[2]<<"\nTotal= "<<total<<"\nAverage= "<<avg;
}
};
void main()
{
int m[]={100,98,99};
result ob1(03,"Rahul Kumar","B.C.A",m);
ob1.display();
getch();
clrscr();
}
No comments:
Post a Comment