Answer to Question #274037 in C++ for manu

Question #274037

Write a program to print the area of a rectangle by creating a class named 'Area' taking the values of its length and breadth as parameters of its constructor and having a function named 'returnArea' which returns the area of the rectangle. Length and breadth of the rectangle are entered through keyboard. 


1
Expert's answer
2021-12-02T17:57:12-0500
#include<iostream>
using namespace std;
class Area{
	public:
		int len,width;
		void getArea(){
			cout<<"Enter the length: ";
			cin>>len;
			cout<<"Enter width: ";
			cin>>width;
		}
		void returnArea(){
			cout<<"Area is: "<<len*width;
		}
};
int main(){
	Area A;
	A.getArea();
	A.returnArea();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment