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

C++ Prac

shjbcjhvcjh shvdhjsbjhsbjsvhdgv

Uploaded by

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

C++ Prac

shjbcjhvcjh shvdhjsbjhsbjsvhdgv

Uploaded by

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

1 Write a C++ program that finds the maximum value among:

1. Two integers.
2. Three floating-point numbers.
3. Two strings (lexicographically greater string).
Overload the max function to handle these scenarios. Input various sets of values
to test each overloaded function.

2
Define two classes, Circle and Cylinder.

 Circle should have an attribute for radius.


 Cylinder should have attributes for radius and height.
 Write a friend class CylinderOperations that can:
1. Access the radius of a Circle to calculate its area.
2. Use the radius of a Circle and the height of a Cylinder to calculate
the volume of the cylinder.

Demonstrate the use of the friend class to calculate the area of a circle and the
volume of a cylinder.

3 Write a program in C++ to Create a Book class to represent books in a library. The
class should have the following
attributes:

 Title (string)
 Author (string)
 ISBN (string)
 Price (double)

Include the following methods:


1. A method to input book details.
2. A method to display book details.
3. A method to check if the price of the book is within a given budget.

Create objects for 3 books, input their details, and display the ones within a
specified budget.

4 Create a base class Rectangle that contains properties and functions to calculate the
area perimeter of a Rectangle. Derive a class cuboid from Rectangle, which includes
additional functionality to calculate the surface area and volume of a Cuboid. write
main program in C++ to calculate surface area and volume of the cuboid.

5
Define a Rectangle class with the following attributes:

 Length (double)
 Breadth (double)

The class should include:

1. A method to set the dimensions.


2. A method to calculate the area.
3. A method to calculate the perimeter.

Create multiple objects to represent different rectangles and calculate their area and
perimeter.

6
Write a C++ program that calculates the area of different shapes using function
overloading. Implement the following overloaded functions:

1. double area(double radius) for the area of a circle.


2. double area(double length, double breadth) for the area of a
rectangle.
3. double area(double base, double height, double dummy) for the
area of a triangle (use the dummy parameter to differentiate).

Demonstrate the use of these functions by calculating the area of a circle (radius =
7), a rectangle (length = 5, breadth = 10), and a triangle (base = 6, height = 8).

7 Write a program in C++ to overload the * and / operator to Multiply and divide two
complex numbers.

8
Create a C++ program that calculates the volume of different geometric shapes
using function overloading:

1. double volume(double side) for the volume of a cube.


2. double volume(double radius, double height) for the volume of a
cylinder.
3. double volume(double length, double breadth, double height)
for the volume of a rectangular box.

Test the functions with a cube of side 4, a cylinder with radius 3 and height 5, and a
box with dimensions 2, 3, and 4.

9 Write a program in C++ to Define two classes, Circle and Cylinder.

 Circle should have an attribute for radius.


 Cylinder should have attributes for radius and height.
 Write a friend class CylinderOperations that can:
1. Access the radius of a Circle to calculate its area.
2. Use the radius of a Circle and the height of a Cylinder to calculate the volume of
the cylinder.

Demonstrate the use of the friend class to calculate the area of a circle and the
volume of a cylinder.

10 Write a program in C++ to calculate the grade of a student using a function. The
function should take three integer parameters representing the marks in three
subjects and return the average. Use another function to determine the grade based
on the average:

 Average >= 90: Grade A


 Average >= 80: Grade B
 Average >= 70: Grade C
 Average >=60: Grade D
 Average < 60: Grade F

11
Design two classes, BankAccount and InterestCalculator.

 BankAccount should have attributes for the account balance.


 InterestCalculator should have attributes for the interest rate.
 Write a friend function to calculate and display the interest for a given
account balance using the interest rate.

Demonstrate the use of the friend function to calculate the interest for multiple
accounts.

You might also like