#include<stdio.h>
#define SIZE 7
int recursiveMinimum( int a[], int size );
int main(void) {
int a[ SIZE ] = { 5, 7, 4, 3, 5, 1, 3 }; // Number 2 is not initialized.
printf( "The smallest number is %d", recursiveMinimum( a, SIZE ) );
return 0;
}
int recursiveMinimum( int a[], int size ) {
static int min ;
static int i = 0;
min = a[ i ];
if( a[ i + 1 ] < min ) {
min = a[ i + 1 ];
}
i++;
if( i == size ) {
return min;
} else {
return recursiveMinimum( a, size );
}
}
So why does it print 2?
staticvariables inrecursiveMinimum().