Model Lab Questions Date: 16.4.
2026
1) Design and implement a C++ program to create an Employee class with data
members such as empID, name, and basicSalary. Include member functions to
calculate the grossSalary (by adding HRA and DA to the basic salary) and to display
the employee payroll details.
a) Create an array of Employee objects to handle multiple employees and
display their payroll information.
b) write a function that accepts an Employee object, evaluates performance-
based incentives, updates the gross salary accordingly, and returns the
updated object.
c) Generate a detailed salary slip for each employee, including earnings,
deductions, and net salary.
2) Create a class Book to manage books in a library. Use a static data member to
track the total number of books.
a) Write a member function to add a new book and increment the static book count.
b) Write a member function to set book details using the this pointer.
c) Write a member function to display book details.
d) Write a member function to check whether two books belong to the same author.
e) Write a member function to display the total number of books in the library.
3) Write a C++ program to create a class Time with data members hours, minutes, and
seconds.
a) Implement a default constructor to initialize time as 00:00:00.
b) Implement a parameterized constructor using the this pointer.
c) Write a function to display time in HH:MM:SS format.
d) Write a function to convert the time into total seconds.
4) Design a C++ program to create a Student class with data members name, rollNo, and
marks.
1. Write a parameterized constructor to initialize student details.
2. Implement a copy constructor to create a duplicate student record.
3. Write a destructor that displays a message when a student object is destroyed.
4. Create objects and demonstrate copying of one student object to another.
5. Create a friend class Result that can access marks and calculate pass/fail status.
5) Create a class Complex with data members for real and imaginary [Link] a C++
program to perform the following tasks:
1. Overload the + operator to add two complex numbers.
2. Overload the - operator to subtract two complex numbers.
3. Overload the == operator to check whether two complex numbers are equal.
4. Overload the << operator to display complex numbers in the form a + bi.
5. Write a main program to input two complex numbers and demonstrate the above
operations.
6) A) Design two classes Kilogram and Gram.
1. Convert a floating-point value into a Kilogram object.
2. Convert the Kilogram object into a floating-point value.
3. Convert a Kilogram object into a Gram object.
B) Write a C++ program to copy the contents of one file into another file using sequential file
access.
7) Design a class Student with data member rollNo.
Derive two classes Test and Sports from Student, where:
Test stores marks
Sports stores sports score
Create a class Result derived from both Test and Sports.
1. Use virtual base class to avoid duplication of Student.
2. Write a program to display roll number, marks, sports score, and total.
8) Design a C++ program to represent geometric shapes using an abstract class Shape with
a pure virtual function area(). Derive classes such as Circle, Rectangle, and Triangle, and
implement the area() function in each class. Accept necessary dimensions from the user and
display the computed area using base class pointers to demonstrate runtime polymorphism.
9) Design and implement a C++ program for a Student Evaluation System using function
overloading. Create a function evaluate() with the following overloaded versions:
1. evaluate(int marks) – Assign a grade based on marks as follows:
o Marks ≥ 90 → Grade A
o Marks ≥ 75 → Grade B
o Marks ≥ 50 → Grade C
o Marks < 50 → Fail
2. evaluate(int marks, int attendance) – If attendance is greater than 85%, add 5 bonus
marks to the original marks and then compute the grade using the above criteria.
3. evaluate(string grade) – Display a remark based on the grade as follows:
o A → Excellent
o B → Good
o C → Average
o Fail → Needs Improvement
Demonstrate all the overloaded functions with suitable input and output.
10) Design and implement a C++ program using a class template <T> to create a generic
stack. The class should include data members such as an array, top, and maximum size,
and initialize the stack using a constructor. Implement member functions push() (with
overflow checking), pop() (with underflow checking), and peek() to view the top element.
Develop a menu-driven program that allows the user to perform push, pop, and display
operations repeatedly until the user chooses to exit.