/* File: min4.c
   A sample program which reports
   minimum values using a better function.
*/

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

/* Function Prototype */
void report_min(int a, int b, string s) ; 

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() ;

   report_min(height1, height2, "height") ;

   report_min(weight1, weight2, "weight") ;
}

/* Function: report_min
   Prints out the smaller of the two arguments.
*/
void report_min(int a, int b, string s) {
   int smaller ;

   if (a < b) {
      smaller = a ;
   } else {
      smaller = b ;
   }
   printf("The smaller %s is: %d\n", s, smaller) ;
}

