Solved

Math

Posted on 1998-11-01
9
208 Views
Last Modified: 2010-04-15
How do I get the square root of a number?
0
Comment
Question by:p314159265
9 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 200 total points
Comment Utility
Answer coming...
0
 
LVL 6

Expert Comment

by:thresher_shark
Comment Utility
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
 
LVL 6

Expert Comment

by:thresher_shark
Comment Utility
If you have any additional questions, please feel free to ask.  Thanks!
0
 

Author Comment

by:p314159265
Comment Utility
What does 'ASSERT' do?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Expert Comment

by:thresher_shark
Comment Utility
"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
 

Author Comment

by:p314159265
Comment Utility
Thanks, that about covers it.
0
 
LVL 5

Expert Comment

by:scrapdog
Comment Utility
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
 
LVL 6

Expert Comment

by:thresher_shark
Comment Utility
Yes, thank you scrapdog for clarifying :-)
0
 
LVL 1

Expert Comment

by:quanghoc
Comment Utility
 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now