I'm trying to add elements to an array with a for loop in C, however something strange is happening. The i variable is effected by the numbers input using scanf.
int intArray[4];
int i;
printf("Input 5 numbers\n");
for(i=0;i<5;i++){
scanf("%d", &intArray[i]);
printf("i: %d\n",i);
}
Examples of outputs:
And any number greater than 3 input constantly works as intended or any number inserted greater than 3 when i = 3
I don't understand why i changes in this for loop in this way.
Any help would be appreciated.

