/* * Calculate the nth root of base, or base to the (1/nth) power. */ #include #include main(argc, argv) int argc; char **argv; { double base, power; if (argc != 3) { fprintf(stderr, "Usage: nthroot , giving b^(1/n)\n"); exit(1); } power = atof(*++argv); base = atof(*++argv); if (power == 0.0) { fprintf(stderr, "Can't divide by 0"); exit(1); } printf("%1.1fth root of %1.1f is %1.20f\n", power, base, pow(base, 1.0/power)); }