please format code with </> button * homework policy * asking questions
for(int iIndex=0;iIndex<6; iIndex++) {
fill(67, 214, 250);
text(iArray[iIndex], (125 + 100 * iIndex), 200);
int iNext= iIndex+1;
while (iNext < 6 ) {
fill(255, 0, 0);
if (iArray[iIndex] == iArray[iNext]) { // getting a error here
text("ERROR, match between number " + (iIndex + 1) + " and " + (iNext + 1), 100.0,(400 + iCount * 30));
++iCount;
}
++iNext;
}
}
I’m using random function to store number in the array and the output has to be shown on the window , but when there is 2 similar numbers i have to show a error message.
That where I’m stuck right now because i’m getting “array index out bound expectation 6” error. So what condition i am suppose to put in while function ?