Write a recursive array that gives the min of an array
C
#include <stdio.h> int minInArray(int arr[], int start, int end){ if(start == end){ return arr[start]; } else{ int min = minInArray(arr, start+1, end); if(min < arr[start]){ return min; } else{ return arr[start]; } } } int main() { int arr[] = {4,2,5,3,1,6,8,7}; printf("%d",minInArray(arr,0,7)); return 0; }
1
Get Answers For Free
Most questions answered within 1 hours.