Write a program to print the area of a rectangle by creating a function '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. And return the area of rectangle.
#include<iostream>
using namespace std;
float Area(float length,float breadth)
{
return length*breadth;
}
float returnArea(float length,float breadth){
return Area(length,breadth);
}
int main(){
float length;
float breadth;
cout<<"Enter length: ";
cin>>length;
cout<<"Enter breadth: ";
cin>>breadth;
cout<<"Area of the rectangle: "<<returnArea(length,breadth)<<"\n";
system("pause");
return 0;
}
Comments
Leave a comment