/* LargestWithReturn.c (c) Kari Laitinen http://www.naturalprogramming.com/ 2013-11-26 File created. 2013-11-26 Last modification. */ #include int search_largest_integer( int array_of_integers[], int number_of_integers_in_array ) { int largest_integer = array_of_integers[ 0 ] ; int integer_index = 1 ; while ( integer_index < number_of_integers_in_array ) { if ( array_of_integers[ integer_index ] > largest_integer ) { largest_integer = array_of_integers[ integer_index ] ; } integer_index ++ ; } return largest_integer ; } int main() { int first_array[] = { 44, 2, 66, 33, 9 } ; int second_array[] = { 888, 777, 66, 999, 998, 997 } ; int found_largest_integer = search_largest_integer( first_array, 5 ) ; printf( "\n The largest integer in first_array is %d.\n", found_largest_integer ) ; printf( "\n The largest integer in second_array is %d.\n", search_largest_integer( second_array, 6 ) ) ; }