Write a float function rectangle() that computes and returns the area of a rectangle using its two float formal parameters h and w, where h is the height and w is the width of the rectangel
#include<iostream>
using namespace std;
float rectangle(float h, float w)
{
return h*w;
}
int main()
{
float height;
float width;
do
{
cout<<"Please, enter a height of rectangle (0 - exit program): ";
cin>>height;
if(height<=0)break;
cout<<"Please, enter a width of rectangle: ";
cin>>width;
cout<<"The area of rectangle is "<<rectangle(height,width)<<endl;
}while(true);
}
Comments
Leave a comment