// Name: // Class and Section: CS 54, Section // Date: February 19, 2007 // Purpose: To write functions for the new TI 42 #include "lab06.h" /* this takes in a real base & an integral exponent, finds base ** exponent and returns the result */ double power(double base, int exponent) { int i; double answer = 1.0; /* if the exponent is positive */ if (exponent >= 1) { for (i = 0; i < exponent; i++) { answer = answer * base; } } /* if the exponent is negative */ else if (exponent <= -1) { for (i = exponent; i < 0; i++) { answer = answer * (1.0 / base); } } /* if the exponent was 0, this will still be 1.0 */ return answer; } // implement all the functions here