I'm running the following programs in Visual C++ and Java:
Visual C++
void main()
{
int i = 1, j;
j = i++ + i++ + ++i;
printf("%d\n",j);
}
Output:
6
Java:
public class Increment {
public static void main(String[] args) {
int i = 1, j;
j = i++ + i++ + ++i;
System.out.println(j);
}
}
Output:
7
Why the output in these two languages are different? How both the langauges treat pre and postincrement operators differently?