functions in C++???

This is a discussion on functions in C++??? within the C++ Programming forums, part of the General Programming Boards category; hi... can some one help me start this problem for me.. i'm knew to C++ at the moment.. i have ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    2

    functions in C++???

    hi...
    can some one help me start this problem for me..

    i'm knew to C++ at the moment..

    i have to write a program based on functions, and basically the info given is to find the height at which the ladder makes contact with the wall, given the length and the distance the base of the ladder is from the wall.

    No angle, length and distance values are given.l


    cheers,
    Kashif.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    Remember the Pythagorean Theorem - "a-squared plus b-squared equals c-squared"? You basically have a right triangle. The length of the ladder is the hypotenuse of the triangle and the distance from the wall is the base of the triangle. Your function simply has to figure out the remaining side. Pass in the two values you do know into the function, then use some of the math functions to calculate and return the result.

    Code:
    double Height( double dLadderHeight, double dDistanceFromWall )
    {
        // Do your calculation here to figure out the value based on the
        // values input into the function.  Basically, just solve the
        // a*a+b*b=c*c equation for either "a" or "b" where "c" is the
        // "dLadderHeight" value and one of the other variables is the
        // "dDistanceFromWall" value.
    }
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    2

    functions in c++....

    Hi!
    Thanx 4 ur help!!
    Could u just check if ive done the prog. correctly?
    Also ive got an exam coming up in a week and a half, i was wondering would u have any examples of mathematical function problems?

    where u use loops make decisions but not really hard qs just to use some of the math functions. Would u also know any sites i can go into to view some of these example problems.


    Thanks 4 ur help...
    Kashif

  4. #4
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Ahhh.......if you want him to check if you've done it correctly, shouldn't you post the code?

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    1)finds the factorial of a number through iteration.

    2)finds the sum of that number and all numbers below it greater than 0, you know like that weird looking E thing

    They are pretty much alike and i'm too tired to be creative right now. So, go and practice.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 02:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21