Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- double num,high, low, mid;
- printf("Please enter a number: \n");
- scanf("%lf", &num);
- low = 0;
- high = num;
- int a = 100;
- while (a--) {
- mid = low + (high-low)/2;
- if (mid*mid > num) high = mid - 10e-7;
- else if (mid*mid < num) low = mid + 10e-7;
- else break;
- }
- printf("Square-Root: %.6lf\n", mid);
- main();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement