/* * question5.c * FINAL * BY: John Stile * Purpose: Given the following program, * write a simple function that takes an integer value as an argument. * Regardless of what number is passed to the function, * the funciton should: * return 1 if the number is positive, * return -1 if the number is negeitve. * return 0 if number is zero. */ #include // prototypes int number_tester( int ); // int main(void) { int number; char input[6]; printf("\nInput an integer: "); gets(input); number=atoi(input); printf("Answer: %d\n", number_tester(number) ); return 0; } // funcitons int number_tester( int x ) { if ( x == 0 ) // if x contains zero, do block { return x; // return 0 to calling function } else { return ( ( x<0) ? -1:1 ); // evaluate if num<0 // if true, return -1 // if flase, return 1 } }