Public Group

Archived

This topic is now archived and is closed to further replies.

C++ Square Roots

This topic is 5394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Ok, so heres the deal... I like to think of myself as an OK programmer. I''m no really into the heavy math yet, I''m still on simple little functions and stuff. So here is my story. The other day I was doing my physics homework for my 9th grade class. I had done about a gizillion of the same problems in a row. You know the type: D = (((time squared) * gravity) /2) This would get you the vertical distance for an object falling toward earth with a gravity that you can input. My program worked! I had a few problems in the beginning, but they were all sorted out. My new question is for another of my homework cheating tools.(haha) I want to try to use this formula now: (((Distance * 2) / Gravity)) and then it would take the square root of everything between the first and last perenthesis. How would I take a square root of all of that? Help would be greatly appreciated on this one. Ah the joys of making a faster way to do my homework. lol -Thanks

Share on other sites
include math.h and use the function sqrt()

daveandrews.org, soon to be home to a GAPI Sprite Engine.

Share on other sites
quote:
Original post by Fruny
The sqrt() function is found in the cmath header.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Roger that.. Thanks Deprecation Nazi I strive to be standard.

daveandrews.org, soon to be home to a GAPI Sprite Engine.

Share on other sites
quote:
Original post by Ronin Magus
Roger that.. Thanks Deprecation Nazi I strive to be standard.

Heh, I had not even seen your post, but if you wish to consider that as a deserved lashing, be my guest

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share on other sites
Thanks a lot guys!
Now I have a whole set of physics homework helper outers. This would include:
Vertical Distance Formulas, Horizontal Distance Formulas, and now the time formula.
-Thanks for the help!

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
17
5. 5

• 14
• 14
• 11
• 9
• 9
• Forum Statistics

• Total Topics
631757
• Total Posts
3002123
×