OOP Problem Statements
OOP Problem Statements
Write a C++ program that takes two integers as input from the user and performs the
following operations:
1. Addition
2. Subtraction
3. Multiplication
Write a C++ program that demonstrates the use of pre-increment (++i), post-increment
(i++), pre-decrement (--i), and post-decrement (i--) operators on an integer variable. The
program should print the results before and after each operation.
Write a C++ program that accepts two integers from the user. The program should check
the following conditions using relational and logical operators:
3. Whether both numbers are either greater than 10 or less than 20.
Write a C++ program that calculates the compound interest on a principal amount. The
program should use the following formula for compound interest:
Where:
The program should ask for the principal amount, rate of interest, and time period, then
compute and display the final amount and the interest.
Write a C++ program to calculate the area of a triangle given the lengths of its three
sides using Heron's formula:
Where:
The program should take the lengths of the sides as input, compute the area, and print
the result. If the sides do not form a valid triangle, print an error message.
Problem 6: Matrix Multiplication
Write a C++ program that multiplies two matrices. The program should:
The program should ensure that the multiplication is possible by checking if the number
of columns in the first matrix is equal to the number of rows in the second matrix.
PRACTICAL 2
The student has scored more than 60% in Mathematics, Physics, and Chemistry.
Write a program that takes age and marks in these subjects as input and determines if
the student is eligible
4. Exit
Create a class Rectangle with attributes for length and width. Implement methods to
set the dimensions, calculate the area, and display the area.
Design a class Calculator with methods to add, subtract, multiply, and divide two
numbers. Allow the user to input the numbers and choose the operation.
Create a class Student to store a student's name, roll number, and marks in three
subjects. Implement a method to calculate the total marks and display the student's
details along with the total marks.
4. Circle Operations
Create a class Circle with an attribute for the radius. Implement methods to calculate
the circumference and area of the circle and display the results.
5. Book Information
Design a class Book to store the title, author, and price of a book. Implement methods
to set the details, display the details, and calculate a discounted price (e.g., 10% off).
7. Design a class BankAccount to model a banking system. The class should have
attributes like account number, account holder's name, and balance. Implement
methods to perform operations such as deposit, withdraw, and check balance,
ensuring proper handling of invalid transactions (e.g., withdrawing more than the
current balance).
PRACTICAL 4
Ensure the program prompts the user for input, determines which function to call based
on the arguments provided, and displays the correct results.
Q.2 Develop a C++ program that demonstrates runtime polymorphism using virtual
functions in an inheritance-based shape hierarchy..Create a base class Shape with the
following:
3. Allow user input for shape dimensions and display the calculated areas
dynamically.
PRACTICAL 5
Problem Statement:
Design a Complex class with:
● real (double)
● imag (double)
To demonstrate the concept of friend functions and friend classes in C++, where a
function or class is given access to private and protected members of another class
without being a member of that class.
Problem Description:
○ length (integer)
○ width (integer)
Constraints:
● The friend function should be non-member but have access to private members.
● The friend class should be able to modify the private members of Rectangle.
● The main function should demonstrate the usage of both the friend function and
friend class.
Expected Output:
● The program should display the original and modified dimensions of the
rectangle.
● It should correctly compute and display the area using the friend function.
Problem Description:
○ accountNumber (integer)
○ accountHolderName (string)
○ balance (double)
● Friend Function:
● Friend Class:
2. Transaction Class
○ transactionID (integer)
○ transactionAmount (double)
Functional Requirements:
○ The user provides account details (account number, name, and initial
balance).
○ processTransaction() can:
Constraints:
● Friend Function Control: Only specific friend functions can modify private data.
Expected Output:
4. Use BankManager to change the account holder’s name and reset the account.
Problem Statement:
Create a class Employee with the following attributes:
● id (integer)
● name (string)
● salary (double)
● A copy constructor that copies an existing employee’s details into a new object.
Problem Statement:
Design a Rectangle class with the following attributes:
● length (float)
● width (float)
● A member function area() that calculates and returns the area of the rectangle.
Write a program that creates a Rectangle object using the parameterized constructor
and displays its area.
Problem 3: Complex Number Operations (Parameterized Constructor & Operator
Overloading)
Problem Statement:
Design a Complex class with:
● real (double)
● imag (double)
Write a program that takes two complex numbers as input, performs addition and
multiplication, and displays the results.
Problem Statement:
Develop an Item class that has:
● itemCode (string)
● itemName (string)
● price (double)
● quantity (integer)
Requirements:
1. Define a base class called Person with the following attributes and methods:
2. Define a derived class called Student that inherits from Person. It should have:
Create an object of the Student class, assign values to all attributes, and call the
methods to display the details.
Objective:
Develop a program to manage employee details using single inheritance. The system
should include basic employee attributes and extend functionality for specialized
employees.
Requirements:
o Attributes:
o Method:
2. Create a derived class Manager that inherits from Employee and includes:
o Additional attributes:
o Method:
3. Create another derived class Developer that inherits from Employee and
includes:
o Additional attributes:
4. Implementation:
Develop a program that demonstrates single inheritance with advanced features such
as method overriding, additional attributes, and multiple operations. The scenario
involves a base class representing a general Bank Account and a derived class for a
Savings Account with extra functionalities.
Requirements:
o Attributes:
o Methods:
▪ deposit(amount): Increases the balance by the specified amount.
o Additional Attribute:
o Additional Methods:
3. Implementation Details:
Objective:
Problem Description:
2.
Requirements:
Develop a class in C++ to model a simple bank account that demonstrates the concept
of data encapsulation. The class should encapsulate the account's details such as
account number, account holder's name, and account balance. Users should be able
to:
3. Withdraw funds from the account (only if there are sufficient funds).
The internal details of the account should not be accessible directly from outside the
class. Instead, users should interact with the account through public member
functions.
PRACTICAL 9
Q.2 Develop a C++ program that demonstrates runtime polymorphism using virtual
functions in an inheritance-based shape hierarchy..Create a base class Shape with the
following:
6. Allow user input for shape dimensions and display the calculated areas
dynamically.
● Create a base class Employee with common attributes and a function to display
basic employee details.
Each derived class should override the display function to show both common and
specific details. The program should allow creating instances of each class and
displaying their information.
PRACTICAL 10
Objective
Requirements
3. Implementation Guidelines:
Objective
Design and implement a file management system that properly handles exceptions
during file operations such as reading, writing, and deleting files.
Requirements
o Methods:
3. Implementation Guidelines:
o Ensure the system does not crash due to unexpected file errors.
Objective
Requirements
o Classes:
3. Implementation Guidelines:
o Ensure the system can continue running smoothly even if an error occurs.
Problem:
Create a function template in C++ that takes two values of any data type and swaps
them.
Requirements:
o Integers
o Floating-point numbers
o Characters
Problem:
Create a function template in C++ that can work with multiple data types and perform
an advanced operation. Specifically, implement a function template named
findMaxWithIndex that:
Requirements:
o An integer array.
o A floating-point array.
o A character array.
Problem:
Create a class template in C++ that can store and perform basic operations on two
values of the same data type. The class should allow users to:
Requirements:
Set values.
Get values.
Integers
Floating-point numbers
Characters
Declare variables of different data types and assign values to them. Print these
values.
Write a program to take two numbers as input and perform arithmetic operations.
The program should print the results before and after each operation.
Problem Statement:
Write a program in C++ to read 5 integers from the user, store them in an array, and
calculate the sum of all the elements using a for loop.
Problem Statement:
Write a program in C++ to add two 2x2 matrices. Use a two-dimensional array and for
loops to compute the result.
Problem Statement:
Write a C++ program to reverse the elements of a single-dimensional array using a for
loop.
Problem Statement:
Write a program in C++ to find the transpose of a 3x3 matrix using for loops.
Write a program that takes the number of a month (1-12) as input and outputs the name
of the month and its corresponding season using a switch statement.
Write a program that acts as a simple calculator. The user provides two numbers and an
operator (+, -, *, /, %) as input. Use a switch statement to perform the corresponding
operation. Handle division by zero and invalid operators gracefully.