/* This modification of the max function illustrates local variables */

#include <iostream.h>

int max(int, int); /* Prototype lists parameter types */

/* This main function computes the maximum of 3 numbers entered by
   the user, by calling max twice. */

main() {
   int a, b, c, largest;

   /* Prompt for 3 numbers */
   cout << "Enter a number: ";
   cin >> a;
   cout << "Enter a number: ";
   cin >> b;
   cout << "Enter a number: ";
   cin >> c;

   /* Use the max function to find the larger of the first two numbers,
      storing the result in largest. */
  
   largest = max(a, b);
 
   /*  Now use max again to compare the result with z */

   largest = max(largest, c);

   cout << "The largest of those three numbers is " << largest << "\n";

   } /* end of main function */


/* The max function takes two integers as input parameters, and returns 
   an integer corresponding to the larger of the two. */

/* Note that we are using some of the same variable names as in main
   above. Since all of these are local variables, it does not matter */

int max(int b, int c) { /* List each parameter separately */

  if (b > c) {return b;}

  else {return c;}

  } /* end of max function */

