C Code: The following code shows how to get the square root without using the function in C.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <stdio.h> #include <math.h> main() { float number; printf("Enter a Number :"); scanf("%f",&number); float result; float squareRoot = number / 2.0; do { result = squareRoot; squareRoot = (result + (number / result)) / 2.0; } while ((result - squareRoot) != 0); printf("%.2f",squareRoot); } |
Output: