-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa141be
commit d043219
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Problem statement | ||
Design a class called Rectangle. | ||
It contains two data members as length(L) and breadth(B); | ||
and a member function getArea(). | ||
The member function computes the area of the given | ||
rectangle and returns it to the caller. | ||
|
||
Note: | ||
|
||
Area of a rectangle = length x breadth | ||
Data Members: | ||
1. length: Length of the rectangle | ||
2. breadth: Breadth of the rectangle | ||
Member Functions: | ||
1. getArea(): that calculates the area of the rectangle | ||
and returns the value. | ||
Note: | ||
|
||
You do not have to take input, just create the Class | ||
and set the name of the Data Members and function as | ||
given in the above discription. | ||
|
||
#include <bits/stdc++.h> | ||
class Rectangle { | ||
public: | ||
int length; | ||
int breadth; | ||
|
||
int getArea(){ | ||
int area = length * breadth; | ||
return area; | ||
} | ||
|
||
}; |