How to find the index of the maximum value in an array? Say we have an array named myMeasurements 

int myMeasurements[9]={3,4,8,12,7,2,1,67,8};


How can I find the index of the maximum element of this array?

For example the MATLAB code would be:

myMeasurements = [3,4,8,12,7,2,1,67,8];
[maxValue,Index] = max(myMeasurements);


where maxValue is returned as 67 whereas the Index is returned as 8.

For the record, I am using Teensy 3.2 and I program it with the Arduino IDE using the Teensyduino add-on.
First of all, do you really need int values for the measurements or not? If not, and you have numbers between 0 and 255, switch the values to byte, your microcontroller will thank you.

Then, there is a problem with the other answers, which is... The variables cannot be left uninitialized!!! You can use this code to get the info you need:

(I also put the size of myMeasurements in a const variable.. You can thank me later for this)

const byte maxMeasurements = 9;
int myMeasurements[maxMeasurements ]={3,4,8,12,7,2,1,67,8};

byte maxIndex = 0;
int maxValue = myMeasurements[maxIndex];

for(byte i = 1; i &lt; maxMeasurements; i++)
{
    if(myMeasurements[i] &gt; maxValue) {
        maxValue = myMeasurements[i];
        maxIndex = i;
    }
}