Click here to Skip to main content
15,883,839 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C++
#include <iostream>
using namespace std;

int getLength(int&);
int getWidth(int&);
double getArea(double lengthNum, double widthNum);
void displayData();

int main(){
    int length, width; 

    
    getLength(length);
    getWidth(width);
    getArea(length, width);
    displayData();
    
    system("pause");
    return 0;
}

int getLength(int& lengthValue)
{
    
    
    cout << "Enter the length: ";
    cin >> lengthValue;
    
    if (lengthValue < 0)
    {
        cout << "\nERROR: Enter a positive number.\n";
        cout << "Enter the length: ";
        cin >> lengthValue;
        cout << endl;
    }
    return lengthValue;
}

int getWidth(int& widthValue)
{
   
    
    cout << "Enter the width: ";
    cin >> widthValue;
    
    if (widthValue < 0)
    {
        cout << "\nERROR: Enter a positive number.\n";
        cout << "Enter the width: ";
        cin >> widthValue;
        cout << endl;
    }
    return widthValue;
}

double getArea(double lengthNum, double widthNum)
{
    return lengthNum * widthNum;
}
//ERROR in here please HELP....Thanks in advance :)!
void displayData()
{
   
    cout << "Rectangle Data\n";
    cout << "--------------\n";
    cout << "Length: " << getLength << endl;
    cout << "Width: " << getWidth << endl;
    cout << "Area: " << getArea << endl;
}
Posted
Updated 26-Apr-15 14:38pm
v2

1 solution

It all makes no sense at all. What are you trying to output when you write the operand getLength, which is a function, but not its call? You probably meant to call this function, but that could be done by getLength(&someIntObject).

The signature of this function also does not name sense, set aside its implementation. If you want to return value, you need just return it. You assign the value by reference and then also return it.

Nothing in this code makes any sense. There is nothing to fix. You need to go back to the very basics of programming: variables, functions, parameter passing methods, addresses and pointers, and so on. Try to read on the basic topics thoroughly and understand them; this is all I can advise at the moment.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900