#include <stdio.h>
// find the max value between a[m] and a[n]
int getmax(int a[],int m, int n)
{
int middle,max1,max2,max;
if( m==n ) max =a[m];
else if(m == n-1)
{
if( a[m] > a[n]) max = a[m];
else max = a[n];
}
else
{
middle = (m+n)/2;
max1=getmax(a,m,middle);
max2=getmax(a,middle+1,n);
if(max1 > max2) max = max1;
else max = max2;
}
return max;
}
void main()
{
int max;
int num_elem = 5;
int array[5] = {20,21,22,23,24};
max=getmax(array,0,num_elem-1);
printf("The max is %d/n",max);
}