I am Anwar as a intermediate level currently programming practice in c, c++ and java . In following programs I confused in these expressions that expressions are same but result are different on these results few teachers said it is the problem of compilers.
In Turbo C 3.0
main()
{
[INDENT]int x=-250;[/INDENT]
[INDENT]x = --x + --x + --x;[/INDENT]
[INDENT]printf("%d",x);[/INDENT]
}//[B]it give -259[/B]
In Visual C++ 6.0
#include<iostream>
using namespace std;
main()
{
[INDENT]int x=-250;[/INDENT]
[INDENT]x = --x + --x + --x;[/INDENT]
[INDENT]cout <<x; [/INDENT]
}//[B]it give -257[/B]
In Java 1.3
class Test
{
public static void main(String abc[])
{
[INDENT]int x=-250;[/INDENT]
[INDENT]x = --x + --x + --x;[/INDENT]
[INDENT]System.out.print(x); [/INDENT]
}//[B]it give -256[/B]