-
April 25th, 2013, 09:18 AM
#1
how to solve this problem? pls help me guyss
Approximating the square root
Implement the sqrt function. The square root of a number, num, can be approximated by repeatedly performing a calculation using the following formula :
nextGuess = (lastGuess + (num / numGuess)) /2
The initial guess can be any positive value (e.g., 1). This value will be the starting vale for lastGuess. If the difference between nextGuess and lastGuess is less than a very small number, such as 0.0001, you can claim that nextGuess is the approximated square root of num. If not, nextGuess becomes the lastGuess and the approximation process continues.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|