/* * File: * testexpt.c * Author: * Samuel A. Rebelsky * Version: * 1.0 of March 2003. */ /********************************************************************* * Headers * ***********/ #include #include #include #include "expt.h" /********************************************************************* * Main * ********/ main(int argc, char *argv[]) { double value; int power; /* Sanity check. */ if (argc != 3) { fprintf(stderr, "Usage: %s val power.\n", argv[0]); exit(EXIT_FAILURE); } /* Get the important values. */ value = strtod(argv[1], NULL); power = (int) strtol(argv[2], NULL, 10); /* Do the computation and print the result. */ printf("%f^%d = %f\n", value, power, expt(value,power)); printf("e^(log(%f)*%d) = %f\n", value, power, exp(log(value)*power)); exit(EXIT_SUCCESS); } /* main(int, char **) */