i) note that for an array of size n, the last valid index is n-1
ii) standard recursion (not efficient, btw)

Qt Code:
  1. int FindMin(int mat[MAX],int size)
  2. {
  3. if (size==0) return 0;
  4.  
  5. int min = FindMin(mat, size-1);
  6. return std::min(min, mat[size-1]);
  7. }
To copy to clipboard, switch view to plain text mode 

iii) linear code (faster)

i
Qt Code:
  1. nt FindMin(int mat[MAX],int size)
  2. {
  3. if (size==0) return 0;
  4. int min=mat[0];
  5. for (int=1; i<size; ++i)
  6. min=std::min(min,mat[i]);
  7. return min;
  8. }
To copy to clipboard, switch view to plain text mode 


iv) easiest way: do NOT INVENT THE WHEEL all over again

Qt Code:
  1. #include <algorithm>
  2. int FindMin(int mat[MAX], int size)
  3. {
  4. return *std::min_element(mat, mat+size)
  5. }
To copy to clipboard, switch view to plain text mode 

for such trivial things, the stdlib already offers algorithm that work (if you use Qt classes, Qt offers such algorithms as well)


HTH