I keep getting syntax error that my coding is wrong...please help me ASAP!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zakir1994
    New Member
    • Oct 2013
    • 1

    I keep getting syntax error that my coding is wrong...please help me ASAP!!!

    Code:
    #include <iostream>
    using namespace std;
    void getLength();
    void getWidth();
    void getArea();
    void getdisplayData();
    int main()
    {
    // Get the rectangle's length.
    {
    double length;
    cout << "What is the rectangles length? ";
    cin >> length;
    // Get rectangles width.
    cout << "What is the rectangles width? ";
    cin >> width;
    }
    // Display the rectangle's data.
    {
    getdiplayData(getLength,getWidth, getArea);
    cout << "length = " << endl;
    cout << "width = " << endl;
    cout << "area = " << endl;
    }
    }
    return 0;
    Last edited by Rabbit; Oct 7 '13, 06:08 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You have the basic structure of your functions wrong, functions can not be defined inside other functions a program calling 1 function might look something like this

    Code:
    #include <iostream>
    
    using namespace std;
    
    void getLength();
    
    int main()
    {
      cout << "Main Entered" << endl;
    
      getLength();
    
      cout << "Back in Main, exiting now" << endl;
    
      return 0;
    }
    
    void getLength()
    {
      cout << "getLength called" << endl;
    }

    Comment

    Working...