Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Calculating the square root by iterations */
- #include <stdio.h>
- int main(void) {
- double num = 570.15;
- double root = num / 2;
- double eps = 0.01;
- int iter = 0;
- while( root - num / root > eps ){
- iter++;
- root = 0.5 * (root + num / root);
- printf("Iteration: %d : root = %f\n", iter, root);
- }
- printf("root = %f", root);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement