/* File: min2.c
   A sample program which computes
   minimum values using a function.
*/

#include <stdio.h>
#include "genlib.h"
#include "simpio.h"

/* Function Prototype */
int min(int a, int b) ; 

main() {
   int height1, height2, weight1, weight2 ;
   int min_height, min_weight ;

   printf("Player 1 height: ") ;
   height1 = GetInteger() ;
   printf("Player 1 weight: ") ;
   weight1 = GetInteger() ;

   printf("Player 2 height: ") ;
   height2 = GetInteger() ;
   printf("Player 2 weight: ") ;
   weight2 = GetInteger() ;

   min_height = min(height1, height2) ;
   printf("The lesser height is: %d\n", min_height) ;

   min_weight = min(weight1, weight2) ;
   printf("The lesser weight is: %d\n", min_weight) ;
}

/* Function: min
   Returns the smaller of the two arguments.
*/
int min(int a, int b) {

   if (a < b) {
      return(a) ;
   } else {
      return(b) ;
   }
}
