#include<stdio.h> #include<math.h> int main() { int a; double x1,x2; scanf("%d",a); x1=a; x2=1.0/2*(x1+a/x1); while(fabs(x2-x1)<0.00001) { x1=x2; x2=1.0/2*(x1+a/x1); } printf("%.3f",x2); reurn 0; } /* Main.c: In function 'main': Main.c:7:11: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=] scanf("%d",a); ~^ ~ Main.c:16:3: error: 'reurn' undeclared (first use in this function) reurn 0; ^~~~~ Main.c:16:3: note: each undeclared identifier is reported only once for each function it appears in Main.c:16:8: error: expected ';' before numeric constant reurn 0; ^~ ; */ |
Double click to view unformatted code.