// Test program for countDown of Example 6.6 #include #include using namespace std; int main() { void countDown(int); countDown(5); return 0; } // // Example 6.6. Function to count down from a positive parameter // to 1 and then to print Ignition, Blast off! // Pre: countFrom is a positive integer. // Post: The countdown or an error message has been printed. // void countDown(int countFrom) { if (countFrom <= 0) // invalid argument cout << "ERROR: Counting down from " << countFrom << " <= 0" << endl; else // valid argument { while (countFrom > 0) { cout << setw(5) << countFrom << endl; --countFrom; } cout << "Ignition" << endl; cout << "Blast off!" << endl; } }