/* File: middle.c This program uses a function that returns the middle number of three given integers. */ #include #include "genlib.h" #include "simpio.h" /* Function Prototype */ int middle(int, int, int) ; main(){ int n1, n2, n3, m ; printf("Enter first number: ") ; n1 = GetInteger() ; printf("Enter second number: ") ; n2 = GetInteger() ; printf("Enter third number: ") ; n3 = GetInteger() ; m = middle(n1, n2, n3) ; printf("The middle number is: %d\n", m) ; } int middle(int one, int two, int three) { /* one is the middle */ if ( (two <= one) && (one <= three) ) return(one) ; if ( (three <= one) && (one <= two) ) return(one) ; /* two is the middle */ if ( (one <= two) && (two <= three) ) return(two) ; if ( (three <= two) && (two <= one) ) return(two) ; /* three is the middle */ if ( (one <= three) && (three <= two) ) return(three) ; if ( (two <= three) && (three <= one) ) return(three) ; }