Results 1 to 5 of 5

Thread: Those who know C++, I require assistance!

  1. #1
    Junior Member roastbeef's Avatar
    Join Date
    Sep 2009
    Location
    Puerto Rico
    Posts
    59
    Thanks
    11
    Thanked 7 Times in 6 Posts

    Those who know C++, I require assistance!

    Okay you C++ users! This requires some basic C++ knowledge.

    Now, I'm making a problem for my Computer Programming class that, in a part, I need to write a function.

    The function should be, in c++:

    basal_metabolic_rate<double> = 70 * (weight/2.2)...

    This is the part I'm making a mistake, and it's the power function. I know the power function is, for example, pow(x,y) for x to the power of y. But I'm having problems on raising that small part of "(weight/2.2)".. I should raise that to the power of 0.756

    So if anyone knows how to write that small part of the function in C++, please tell me. This stupid lab is due tonight and I keep doing this small mistake.
    "So it goes."-Kurt Vonnegut

  2. #2
    Senior Member
    Retired Staff
    davepm's Avatar
    Join Date
    Aug 2009
    Location
    Lincoln, Lincolnshire, United Kingdom
    Posts
    4,561
    Thanks
    124
    Thanked 2,059 Times in 831 Posts
    basal_metabolic_rate<double> = 70 * (pow((weight/2.2),0.756))

    would that work?

    dont forget to #define <math.h> if your doing this.

    you could also define a second variable to store (weight/2.2)

    temp_var = (weight/2.2)

    power = pow(temp_var,0.756)

    basal_metabolic_rate<double> = 70 * power


    messy, but might work

  3. 1 User Says Thank You davepm For This Useful Post


  4. #3
    Senior Member messie's Avatar
    Join Date
    Jun 2009
    Posts
    5,118
    Thanks
    68
    Thanked 7,151 Times in 1,065 Posts
    messie does work!!! lol

  5. #4
    Senior Member
    Retired Staff
    davepm's Avatar
    Join Date
    Aug 2009
    Location
    Lincoln, Lincolnshire, United Kingdom
    Posts
    4,561
    Thanks
    124
    Thanked 2,059 Times in 831 Posts
    Quote Originally Posted by messie View Post
    messie does work!!! Lol
    lies!!!!!!

  6. #5
    Junior Member roastbeef's Avatar
    Join Date
    Sep 2009
    Location
    Puerto Rico
    Posts
    59
    Thanks
    11
    Thanked 7 Times in 6 Posts
    Thanks, but the problems were already submitted. But, I'll test it.
    "So it goes."-Kurt Vonnegut

Bookmarks

Posting Permissions

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