/* testfunc13.cpp CIS 150 2008-06-10 David Klick This program demonstrates how to use default arguments. */ #include #include using std::cin; using std::cout; double power(double x, double y = 2.0); void cont(); int main(int argc, char* argv[]) { double a = 4.0; cout << "4 squared is " << power(a) << '\n'; cout << "4 cubed is " << power(a, 3.0) << '\n'; cont(); return 0; } /* double power(double x, double y); Arguments: double x: an arbitrary real number double y: an arbitrary real number Returns: the value of x raised to the y power Calculates the value of one number raised to the power of another number. */ double power(double x, double y) { return pow(x, y); } /* void cont(); Arguments: none Returns: nothing Clears input buffer and pauses waiting for user to press Enter. */ void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); } /* Sample output: 4 squared is 16 4 cubed is 64 */