0% found this document useful (0 votes)
308 views

Inheritence C Lab Exercise

The document describes 5 inheritance lab exercises in C++. Exercise 1 involves single inheritance to add two numbers accepted from the user in the base class and display the sum in the derived class. Exercise 2 involves multi-level inheritance to calculate a student's percentage by accepting subject marks in the base class, finding the total marks in a derived class, and calculating and displaying the percentage in another derived class. Exercise 3 involves inheritance with a Person base class and Employee and Manager derived classes to accept and display details of managers including the highest paid manager. Exercise 4 involves inheritance with an Item base class and DiscountedItem derived class to display an itemized bill and total for n purchased items. Exercise 5 involves inheritance with a Lecture base class and

Uploaded by

Yogendra Kshetri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
308 views

Inheritence C Lab Exercise

The document describes 5 inheritance lab exercises in C++. Exercise 1 involves single inheritance to add two numbers accepted from the user in the base class and display the sum in the derived class. Exercise 2 involves multi-level inheritance to calculate a student's percentage by accepting subject marks in the base class, finding the total marks in a derived class, and calculating and displaying the percentage in another derived class. Exercise 3 involves inheritance with a Person base class and Employee and Manager derived classes to accept and display details of managers including the highest paid manager. Exercise 4 involves inheritance with an Item base class and DiscountedItem derived class to display an itemized bill and total for n purchased items. Exercise 5 involves inheritance with a Lecture base class and

Uploaded by

Yogendra Kshetri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Inheritance Lab Exercise

1. Write a C++ program to add two numbers using single inheritance. Accept
these two numbers from the user in base class and display the sum of these two
numbers in derived class.

2. Write a C++ program to calculate the percentage of a student using multi-level


inheritance. Accept the marks of three subjects in base class. A class will
derived from the above mentioned class which includes a function to find the
total marks obtained and another class derived from this class which calculates
and displays the percentage of student.

3. Write a C++ program to design a base class Person(name, address, phone).


Derive a class Employee(eno, ename) from Person. Derive a class
Manager(designation, dept_name, basic_salary) from Employee. Write a
program to:
Ø Accept all details of ‘n’ managers
Ø Display manager having highest salary

4. Write a C++ program to define a base class Item (item-no, name, price). Derive
a class Discounted-Item (discount-percent). A customer purchases 'n' items.
Display the item-wise bill and total amount using appropriate format.

5. Imagine in a college hires some lectures. Some lectures are paid in period basic,
while others are paid in month basic. Create a classed called lecture that stores
ID and name of lectures. From this class derive two classes: part time, which
adds payperhr (type float); and full time, which adds pay per month (type
float). Each of these three classes should have a readdata () function to gate its
data from user at the key board and printdata () function to display the data.
Write a main ()program to test the Full time and part time claases by creating
instance of them, asking the user to fill thir data with readdate () and display the
data with printdata().

You might also like