Write a C++ program to calculate the area of a rectangle using Class and Constructor. You have to declare a class named as Rectangle. Create data member according to the area of rectangle. Create a parameterized constructor to initialize variables according to the area of rectangle. You have to calculate area using function named as AreaOfRectangle. In int main You must create four objects and initialize different data members. For first object take the data member values as 10 and 20. For second object take the data member values as 20 and 30. For third object take the data member values as 30 and 40. For fourth object take the data member values as 40 and 7.50. Find the output of 4 different Areas by access the member function. YOUR OUTPUT SHOULD BE AS FOLLOWS: Area of Rectangle 1: 200 Area of Rectangle 2: 600 Area of Rectangle 3: 1200 Area of Rectangle 4: 2000
Write a C++ program to calculate the area of a rectangle using Class and Constructor.
You have to declare a class named as Rectangle.
Create data member according to the area of rectangle.
Create a parameterized constructor to initialize variables according to the area of rectangle.
You have to calculate area using function named as AreaOfRectangle.
In int main You must create four objects and initialize different data members.
For first object take the data member values as 10 and 20.
For second object take the data member values as 20 and 30.
For third object take the data member values as 30 and 40.
For fourth object take the data member values as 40 and 7.50.
Find the output of 4 different Areas by access the member function.
YOUR OUTPUT SHOULD BE AS FOLLOWS:
Area of Rectangle 1: 200
Area of Rectangle 2: 600
Area of Rectangle 3: 1200
Area of Rectangle 4: 2000
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images