I'm trying to understand why all following three cases resulted in different output on Visual C++ compiler
Program 1
i = 0;
while ( i < 100)
{
printf( "%d: %d\n", array1[i], array2[i]);
i++;
}
Program 2
i = 0;
while ( i < 100)
{
printf( "%d: %d\n", array1[i], array2[i++]);
}
Program 3
i = 0;
while ( i < 100)
{
printf( "%d: %d\n", array1[i++], array2[i]);
}
As per my understanding, I was expecting that increment operator will increment the value of i after the expression has been evaluated. Initially I thought all three would lead to same output but after seeing output, I was expecting atleast Program 1 and Program 2 output should be same.
However, output was different in all three cases. Please correct me what I am missing here.