#include <iostream>
usingnamespace std;
int main()
{
double length=0.0, // The rectangle's length
width=0.0, // The rectangle's width
area=0.0; // The rectangle's area
// Get the rectangle's length and rectangle's width..
getInput(length, width);
// Get the rectangle's area.
area = getArea(length, width);
// Display the rectangle's length, width, and area.
displayData(length, width, area);
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
double length=0.0,
width=0.0,
area=0.0;
getInput(length, width);
area = getArea(length, width);
displayData(length, width, area);
return 0;
}
void getInput (double length, double width)
{
cout << "Please enter the length and the width of the rectangle. " << endl;
}
double getArea (double length, double width)
{
area = length * width;
return area;
}
void displayData (double area)
{
cout << "The length of the rectangle is " << length << endl;
cout << "The width of the rectangle is " << width << endl;
cout << "The area of the rectangle is " << area << end;
}
I'm pretty sure my professor wants us to pass the values by reference in the getInput function, but that subject is a quite unclear to me, and I'm not even sure how to begin setting that up.
you pass by reference by doing data_type& variable_name this in a way transfers the actual variable instead of the value of the variable. so you are moving the actual variable. and if you are doing