#include <iostream>
usingnamespace std;
// Function prototypes:
void GetValues(double &, double &);
float ComputeArea(double, double);
void PrintArea(double);
int main()
{
float length, width, area;
cout << "This program computes the area of a rectangle." << endl;
cout << "You will be prompted to enter both the length and width.";
cout << endl << "Enter a real number (such as 7.88 or 6.3) for each.";
cout << endl << "The program will then compute and print the area.";
cout << endl;
GetValues(length,width);
ComputeArea (length,width);
PrintArea(area);
return 0;
}
/*
Purpose: To ask the user for the length and width of a rectangle and
to return these values via the two parameters.
Return: Length The length entered by the user.
Width The width entered by the user.
*/
void GetValues(double & l, double & w)
{
l = length;
w = width;
cout << " Enter the length: " ;
cin>> l;
cout << "enter the width: ";
cin>>w;
// add code to get Length and Width
return GetValues() ;
}
/* Given: Length The length of the rectangle.
Width The width of the rectangle.
Purpose: To compute the area of this rectangle.
Return: The area in the function name.
*/
double ComputeArea(doulbe l, double W)
{
int area;
l = length;
W = width;
area = l * W ;
return area;
// add code to compute area
}
/* Given: Area The area of a rectangle.
Purpose: To print Area.
Return: Nothing.
*/
void PrintArea(double a)
{
a = area;
l = length;
W = width;
cout << "The area of the " << length << " by "
<< width << " rectangle is " << area << endl;
// add code to print area of the rectangle
}
Firstly, lines 43, 43 (the same with 65, 66 and 84, 85, 86). 'length' and 'width' are in different scope, so you cannot access them from other functions. Though I don't see, why would you want to, since you pass them as parameters. Remove those lines.
Secondly, in line 51, return GetValues() ; is a recursive call which will prevent you from returning to main. This function is void, so you don't need to return anything. Remove that line as well.
Finaly, function PrintArea here takes only one parameter, but is suposed to print three. Make it void PrintArea(double a, double l, double w);