// Program 4:  MultiHelloWorld.C
// (c) Burt Rosenberg 1996
// This program introduces procedures, local variables and
//   value passing to the local variable, and recursion.

#include<iostream.h>

void sayHello (    // Create a procedure object named sayHello and
   int i  )        // one integer object named i.
                   // Initialize the integer object. 
{
   if ( i <= 0 ) 
   {
      // If i is 0 or less, say World and die.
      cout << "World" << endl ;
   }
   else 
   {
      // If i is positive, say Hello once, decrement
      // i by 1, and instantiate the sayHello block again.
      cout << "Hello" << endl ;
      i = i - 1 ;
      sayHello( i ) ;
   }
}

void main() 
{
   int count ;

   // Get the count
   cout << "Enter the count: " ;
   cin >> count ;

   // Validate the input
   if ( count < 0 )
   {
       cout << "Error: count must be positive." << endl ;
       return ;
    }

   // Say Hello count times.
   sayHello(count) ;
}
