Hey all! I am working on my 4th C++ program and am running into a problem. I am getting error LNK2019 and LNK1120 in Visual Studio. I am trying to get my program to use 4 functions, one to get the length of a rectangle, one to get width, one to accept the width and length and calculate the area, and one to accept all three paramaters and display them.
Anyone see what I am doing wrong here? Says I have unresolved external statements. Thanks in advance for any help!
#include <iostream>
usingnamespace std;
void getLength(float& length); //function prototype
void getWidth(float& width); //function prototype
void getArea(float& length, float& width); //function prototype
void displayData(float& length, float& width, float& area); //function prototype
int main()
{
//variables
float length; //user input for length
float width; //user input for width
float area; //value after calculation
//Get the information from the user
getLength(length);
getWidth(width);
getArea(width, length);
displayData(width, length, area);
}
void getLength(float& length)
{
//Get the length from the user
cout << "Please enter the length of the rectangle: " << endl;
cin >> length;
}
void getWidth(float& width)
{
//Get the width from the user
cout << "Please enter the width of the rectangle: " << endl;
cin >> width;
}
void getArea(float& length, float& width, float& area)
{
area = length * width;
}
void displayData(float& area, float& length, float& width)
{
//Display the area
cout << "The area of a rectangle with a length of " << length << " and a width of " << width << " is: " << area << "." << endl << endl;
cout << "Thank you for using this program!" << endl << endl;
}