I'm trying make a program using a newton-raphson method this formula run 10 times:
yk+1 = 1/2 . (yk + a/yk)
y1 = 1
The code below have some error, the output have return 0.
Help, thank you!
Code:#include <stdio.h> #include <math.h> int main(void) { int k, j, a, b; float y; scanf("%d", &a); for(k = 1; k > a; k++) { y = 1; for(j = 1; 10 < j; j++) { y = (y + a/y)/2; } } printf("%d", y); return 0; }