#include #include #include #include int main(int argc, char **argv) { long double x; long double k; char pszString[256] = "2"; if ( argc < 2 ) { printf( "Enter a number to find square root of:" ); fgets( pszString, sizeof( pszString ), stdin ); puts( pszString ); } else strncpy( pszString, argv[1], sizeof( pszString ) ); k = atof( pszString ); x = powl( k, 1.0e0L/3.0e0L ) * 1.00001; /* form estimate correct to 5 digits */ x += 3*(-x*x*x + k)*x*(2*x*x*x+k)/(10*x*x*x*x*x*x +16*x*x*x*k +k*k); printf("answer = %30.20LeL\nx = %30.20LeL\n", powl( k, 1.0e0L/3.0e0L ), x ); return 0; }