SOURCE FILE: 6.06CountDown.cpp
// Test program for CountDown of Example 6.6
#include <iostream.h>
#include <iomanip.h>
int main(void)
{
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\n";
else // valid argument
{
while (CountFrom > 0)
{
cout << setw(5) << CountFrom << endl;
CountFrom--;
}
cout << "Ignition\n";
cout << "Blast off!\n";
}
}