#include <stdlib.h>
#include <stdio.h>
int recursiveMinimum(int my_array[],unsigned array_size);
int main()
{
int my_array[10]={-11,2,3,-5,3,-94,-7,-1,10,-80};
printf("Current Minimum is : %d\n",recursiveMinimum(my_array,10));
return (0);
}
int recursiveMinimum(int my_array[],unsigned array_size)
{
int current_minimum;
/*Stop condition for the recursion*/
if (array_size == 1)
{
/*Don't forget that there is still one value we didn't check ...*/
return (my_array[array_size - 1]);
}
else
{
/*Call the function recursively to get the minimum in the current sub-array
Note that the current sub array "doesn't contain" the value stored in the top
of the array*/
current_minimum = recursiveMinimum(my_array,array_size - 1);
printf("\n* %d \n", current_minimum);
/*Compare the current_minimum with the value in the top of the array*/
if (current_minimum > my_array[array_size - 1])
{
current_minimum = my_array[array_size - 1];
}
/*Return the current recursion result*/
return (current_minimum);
}
}