The function FindSubArrayMinimum is suppose to return the index of the minimum value in an array between the values (left,right). Instead of returning 1 as it should, it returns 7. 

Here is my code:

```
#include <iostream>
using namespace std;

class Minimum {

int *array;
int arrayLen;

public:

Minimum(int *array, int arrayLen) {
}

void swap(int &a, int &b) {
    int x;
    x = a;
    a = b;
    b = x;
}

int findMinimum(int a, int b) {
    if(a < b){
        return a;
    }else{
        return b;
    }
}

int findArrayMinimum(int a[], int arraySize) {
    int min=a[0];
    for(int i=0;i<arraySize-1;i++){
        if(a[i] < min){
            min = i;
        }
    }
    return min;
}

int findSubArrayMinimum(int a[], int arraySize, int left, int right) {
    int min = a[left];
    for(int i=left;i<right+1;i++){
        if(a[i] < min){
            cout << min << endl;
            min = i;
        }
    }
    return min;
}
int findSubArrayMinimumAndSwap(int left, int right, int swapIndex) {

}

};

int main() {

int A[5] = {47, 7, 21, -1, 11};
Minimum min(A, 5);

cout << "Minimum of 7 and 11 is " << min.findMinimum(7, 11) << endl;

int x = 5, y = 7;
min.swap(x, y);
cout << "x = " << x << ", y = " << y << endl;

cout << "Minimum value is at position " << min.findArrayMinimum(A,5) << endl;
cout << "Minimum value between [1,2] is at position " << 
min.findSubArrayMinimum(A,5,1,2)<< endl;

return 0;
}

```

I cannot for the life of me figure out why it won't return the minimum index. Logically speaking it should work unless I'm missing something?