Answer to Question #339867 in C++ for fahmi

Question #339867

write program to print the area of rectangle by creating class name 'Area' with the method of cumpute area which take the value of it is length and width as parameter and return area of rectangle length and width of rectangle area entered through keyboard


1
Expert's answer
2022-05-11T13:52:12-0400
#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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS