• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • 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
The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

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