Popular Posts

34.Write a program to show the total marks of a particular student of a subject using inheritance .

34.Write a program to show the total marks of a particular student of a subject using inheritance .

#include
#include
class student
{
char name[30];
int roll_no;
public:
void getdata(void);
void putdata(void);
};
void student:: getdata(void)
{
cout<<"Input:\n"; cout<<"Enter student name: "; cin>>name;
cout<<"Enter roll number: "; cin>>roll_no;
}
void student::putdata(void)
{
cout<<"\n\nOutput:\n\n";
cout<<"Student Name: "< <<"Roll Number: "< }
class attendance
{
public:
int att_mark;
void get_att_mark(int);
void put_att_mark(void);
};
void attendance::get_att_mark(int a)
{
att_mark=a;
}
void attendance::put_att_mark(void)
{
cout<<"Attendance Mark: "< }
class final_exam:public student
{
public:
float part_a;
float part_b;
void get_mark(float,float);
void put_mark(void);
};
void final_exam::get_mark(float x,float y)
{
part_a=x;
part_b=y;
}
void final_exam::put_mark()
{
cout<<"\nMarka of Part A: "< <<"Marks of Part B: "< }
class class_test
{
public:
int ct1,ct2,ct3;
void get_ct_mark(int,int,int);
void put_ct_mark(void);
};
void class_test::get_ct_mark(int p,int q,int r)
{
ct1=p;
ct2=q;
ct3=r;
}
void class_test::put_ct_mark()
{
cout<<"Marks of Class Test 1: "< <<"Marks of Class Test 2: "< <<"Marks of Class Test 3: "< }
class result:public attendance,public final_exam,public class_test
{
float total;
public:
void display(void);
};
void result::display(void)
{
total=att_mark+part_a+part_b+ct1+ct2+ct3;
putdata();
put_att_mark();
put_mark();
put_ct_mark();
cout<<"\nTotal= "< }
int main()
{
clrscr();
result s;
s.getdata();
s.get_att_mark(27);
s.get_mark(90.0,85.5);
s.get_ct_mark(19,20,20);
s.display();
getch();
return 0;
}

Output:

Input:
Enter student name: MOHIN
Enter roll number: 1354


Output:

Student Name: MOHIN
Roll Number: 1354
Attendance Mark: 27

Marka of Part A: 90
Marks of Part B: 85.5

Marks of Class Test 1: 19
Marks of Class Test 2: 20
Marks of Class Test 3: 20


Total= 261.5

No comments: