Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    28
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Question why wont it work

    why doesnt this code work?



    #include <iostream>
    #include <cmath> // or math.h

    int main()
    {
    using namespace std;

    double area;
    cout << "Enter the floor area, in square feet, of your home: ";
    cin >> area;
    double side;
    side = sqrt(area);
    cout << "That's the equivalent of a
    << " feet to the side." << endl;
    cout << "How fascinating!" << endl;
    return 0;
    }
    Last edited by saadhamza; 07-05-2009 at 12:41 AM. Reason: ooops

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    I'll bet that your error message has some helpful information.
    Are you a Help Vampire?

  • #3
    Regular Coder adarshakb's Avatar
    Join Date
    Jun 2009
    Location
    Silicon valley of india
    Posts
    247
    Thanks
    11
    Thanked 1 Time in 1 Post
    This code works:
    I noticed error in the pasted code of a missing "
    exactly :
    "<<side<< was missing in the output line
    #include <iostream>
    #include <cmath> // or math.h

    int main()
    {
    using namespace std;

    double area;
    cout << "Enter the floor area, in square feet, of your home: ";
    cin >> area;
    double side;
    side = sqrt(area);
    cout << "That's the equivalent of a "<<side<< " feet to the side." << endl;
    cout << "How fascinating!" << endl;
    return 0;
    }
    lol hope it answered

  • #4
    Regular Coder BrickInTheWall's Avatar
    Join Date
    Mar 2009
    Location
    Munich, Germany
    Posts
    139
    Thanks
    1
    Thanked 13 Times in 13 Posts
    cout << "That's the equivalent of a
    << " feet to the side." << endl;

    there are quotes missing after the 'a' ----> "That's the equivalent of a"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •