Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < stdio.h >
- #include <stdbool.h>
- #include <math.h>
- int main()
- {
- int root;
- float initialValue, squareRoot;
- const eps = 0.01;
- squareRoot = 1;
- printf("Enter a positive integer from 1 to 2147483647\n");
- scanf_s("%d", &root);
- do
- {
- initialValue = squareRoot;
- squareRoot = (initialValue + root / initialValue) / 2;
- } while ((fabs(squareRoot - initialValue) > eps));
- printf("final = %f", squareRoot);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement