Answer to Question #289275 in C++ for Afo

Question #289275

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

1
Expert's answer
2022-01-21T08:24:16-0500
#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);
}

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