SOURCE FILE: 02CountDown.cpp



// Test program for CountDown
   
#include <iostream>
#include <iomanip>

using namespace std ;
  
int main(void)   
{   
   void CountDown(int);   
   CountDown(10);
   
   return 0;   
}  
 
/*
   Example 7.2. Function to count down from positive parameter   
   CountFrom to 1 and then to print Ignition, Blast off!   
   Pre:  CountFrom is a positive integer.   
   Post: The countdown was displayed.   
*/    
   
void CountDown(int CountFrom)   
{   
   if (CountFrom <= 0)            // invalid parameter 
      cout << "ERROR: Counting down from " << CountFrom << " <= 0\n";
   else                           // valid parameter 
   {   
      for (; CountFrom > 0; CountFrom--)   
         cout << setw(5) << CountFrom << endl;
   
      cout << "Ignition\n";
      cout << "Blast off!\n";
   }   
}