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
#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();
}
Comments
Leave a comment