Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include < stdio.h >
  2. #include <stdbool.h>
  3. #include <math.h>
  4. int main()
  5. {
  6. int root;
  7. float initialValue, squareRoot;
  8. const eps = 0.01;
  9. squareRoot = 1;
  10. printf("Enter a positive integer from 1 to 2147483647\n");
  11. scanf_s("%d", &root);
  12. do
  13. {
  14. initialValue = squareRoot;
  15. squareRoot = (initialValue + root / initialValue) / 2;
  16. } while ((fabs(squareRoot - initialValue) > eps));
  17. printf("final = %f", squareRoot);
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement