Question: #include #include #include using namespace std; /* This program reads a width and height of a rectangle. It computes and prints the area, perimeter and

#include

#include

#include

using namespace std;

/*

This program reads a width and height of a rectangle. It computes and

prints the area, perimeter and length of the diagonal of the rectangle.

Written by: Your name here

Date written: Current date here

*/

void compute_rectangle (double width, double height);

int main()

{

double width, // width of the rectangle entered by the user

height, // height of the rectangle entered by the user

area, // area of the given rectangle

perimeter, // perimeter of the given rectangle

diagonal; // diagonal of the given rectangle

cout << "Enter the width of the rectangle: ";

cin >> width;

cout << "Enter the height of the rectangle: ";

cin >> height;

compute_rectangle (width, height);

cout << " The area is: " << area;

cout << " The perimeter is: " << perimeter;

cout << " The diagonal is: " << diagonal << " ";

return 0;

}

void compute_rectangle (double width, double height)

{

double area, perimeter, diagonal;

area = width * height;

perimeter = width * 2 + height * 2;

diagonal = sqrt (width * width + height * height);

}

Then add call by reference parameters to send back the values of area, perimeter and diagonal to main. Change the prototype, function call and function definition to get the program to compile and run correctly.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!