In Turbo C 3.0
#include<conio.h>
#include<stdio.h>
void main(void)
{int x=-250;
x = --x + --x + --x;
printf("%d",x);
getch();
}//it gives: -259
In Visual C++ 6.0
#include<iostream>
using namespace std;
void main(void)
{int x=-250;
x = --x + --x + --x;
cout <<x;
}//it gives: -257
In Java
class Test
{
public static void main(String abc[])
{int x=-250;
x = --x + --x + --x;
System.out.print(x);
}//it gives: -256
I think you mean they give 75* not 25* but anyway
It is based on the order of operations specific to compilers
If Turbo does give 759 and not 259 then it will always perform the decrement operation first on before doing anything resulting in -253 + -253 + -253
In Visual C++ they do the same thing but only look at 2 items at a time so it will take the last items, do the decrements then add them together so you have -250 decremented, then -251 decremented resulting in -252 + -252 giving -504. -504 is then added to x decremented which is -504 + -253 giving -757
Java decrements then adds so x is decremented to -251 and added to that decremented -252 which is added to that decremented -253 resulting in -756
Parenthesis would help resolve how you want it evaluated