C++ Square Roots

Started by
4 comments, last by jedis1000 20 years, 6 months ago
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
Advertisement
include math.h and use the function sqrt()

daveandrews.org, soon to be home to a GAPI Sprite Engine.
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 ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
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.
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 ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
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!

This topic is closed to new replies.

Advertisement