fork download
  1. #include <stdio.h>
  2. #define SIZE 10
  3.  
  4. int recursiveMinimum(const int b[], size_t low, size_t high);
  5.  
  6. int main(void) {
  7. int a[SIZE] = {12, 5, 8, 2, 9, 15, 3, 20, 7, 11};
  8.  
  9. int min = recursiveMinimum(a, 0, SIZE - 1);
  10.  
  11. printf("Minimum value in the array is: %d\n", min);
  12.  
  13. return 0;
  14. }
  15.  
  16. int recursiveMinimum(const int b[], size_t low, size_t high) {
  17. if (low == high) {
  18. return b[low];
  19. }
  20.  
  21. int min = recursiveMinimum(b, low + 1, high);
  22.  
  23. if (b[low] < min) {
  24. return b[low];
  25. } else {
  26. return min;
  27. }
  28. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Minimum value in the array is: 2