find on google, You can get easily... ... Code: #include <stdio.h> int main () { int arr[] = {1, 20, 9, 12, 19, 17, 10, 5}; printf ( "%d\n", arr[FindMaxArr ( arr, 0, 8 )] ); return 0; } int FindMaxArr( int arr[], int lMost, int rMost ) { if ( lMost == rMost - 1 ) return lMost; rMost = FindMaxArr( ( arr, lMost+ 1, rMost); return arr[rMost] > a[lMost] ? rMost : lMost; }
Sorry to tell you but again your this code has compilation error. 1. First you have to give the signature of the function before main if you define it after main. So you have to write this line before main Code: int FindMaxArr( int arr[], int lMost, int rMost ); 2. Second there is an extra "(" when calling function recursively. It should be like this Code: rMost = FindMaxArr ( arr, lMost+ 1, rMost); 3. Third there is no variable named "a" it should be arr like this Code: return arr[rMost] > arr[lMost] ? rMost : lMost;