0% found this document useful (0 votes)
17 views3 pages

Prc13 Output

Uploaded by

itzinnovator01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Prc13 Output

Uploaded by

itzinnovator01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Q1

#include <iostream>
using namespace std;

class area {
public:
int l, b;
area(){
l=10;
b=5;
}
};

class perimeter {
public:
int l1, b1;
perimeter() {
l1=5;
b1=2;
}
};

class rectangle : public area, public perimeter {


public:
int ar, per;
void display() {

ar = l*b;
per = 2 * (l1+b1);
cout << "Area: " << ar << "\nPerimeter: " << per;
}
};

int main() {

rectangle r;
r.display();

return 0;

}
Q2
#include <iostream>
using namespace std;

class cricketer {
protected:
char name[20];
int score;
public:
void get1() {
cout << "Enter Cricketer Name and Score: ";
cin >> name >> score;
}
void put1() {
cout << endl << "Cricketer Name: " << name << endl;
cout << "Score: " << score << endl;
}
};

class bowler : virtual public cricketer{


protected:
char bo_name[20];
int wickets;
public:
void get2() {
cout << "Enter Bowler name and wickets taken:\n";
cin >> bo_name >> wickets;
}
void put2() {
cout << "\nBowler Name: " << bo_name << endl;
cout << "Wickets: " << wickets<< endl;
}
};

class batsman : virtual public cricketer{


protected:
char ba_name[20];
int runs;
public:
void get3() {
cout << "Enter Batsman Name and Run:\n";
cin >> ba_name >> runs;
}
void put3() {
cout << "\nBatsman Name: " << ba_name << endl << "Runs: " << runs<< endl;
}
};

class allrounder : public bowler, public batsman{


protected:
char a_name[20];
int a_score;
public:
void get4() {
cout << "Enter Allrounder name and score:\n";
cin >> a_name >> a_score;
}
void put4() {
cout << "\nAllrounder Name: " << a_name << endl;
cout << "Score: " << a_score<< endl;
}
};

int main(){

allrounder a;

a.get1();
a.get2();
a.get3();
a.get4();
a.put1();
a.put2();
a.put3();
a.put4();

return 0;
}

You might also like