• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Math

How do I get the square root of a number?
0
p314159265
Asked:
p314159265
1 Solution
 
thresher_sharkCommented:
Answer coming...
0
 
thresher_sharkCommented:
To calculate the square root of a number, use the sqrt function like so:

#include <math.h>
.
double number = 4.0;
double result = sqrt (number);
ASSERT (result == 2.0);
0
 
thresher_sharkCommented:
If you have any additional questions, please feel free to ask.  Thanks!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
p314159265Author Commented:
What does 'ASSERT' do?
0
 
thresher_sharkCommented:
"ASSERT" performs a test that, if failed, will stop the program's execution.  In this case, it is basically saying, "If the square root of 4 is not 2, then stop the program from running."  Obviously, you would want that to happen because the square root of 4 is obviously 2.

If you have further questions, please ask.  Thanks!
0
 
p314159265Author Commented:
Thanks, that about covers it.
0
 
scrapdogCommented:
Of course, you don't NEED to use ASSERT...  Thresher just put it there as a code snippet to prove that the sqrt function works.

a=sqrt(b) is the only code you really need.
0
 
thresher_sharkCommented:
Yes, thank you scrapdog for clarifying :-)
0
 
quanghocCommented:
 I think you can use this function to get n root of a
Give a = x^n
=> x = exp((1/n)*log(a))
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now