Q:

Finding min elements index in array

I can find min value index in my array. I found a lot of guides about it and I am doing the same, but my answer isn't correct.
    double minimum = main_array[0];
    int index_min;

    for (int i=1; i<ARRAY_SIZE; i++) {
        if (main_array[i] < minimum)
            minimum = main_array[i];
            index_min = i;
}

The answer what I get is index of last element in the array, not the element with lowest value.

A:

You need to properly wrap the if condition when you update index_min :
  if (main_array[i] < minimum) {
            minimum = main_array[i];
            index_min = i;
  }

