[Dev-C++] Question about increment..
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Mani <man...@gm...> - 2012-09-20 16:54:29
|
Hi,
I recently to try some toy things in DevC++ (version I am using is 4.9.9.2)
The code I had was this:
int a = 1, b = 2;
int c = a++ + b++ + a + b;
cout << "a = " << a << endl;
cout << "b = " << b << endl;
cout << "c = " << c << endl;
I expected the c value to be 8 (by operator precedence, ++ has higher
precedence than +, so do in order:
a++, then b++
then do (a++ + b++)
then add the previous result and a
then add the previous result and b
but the answer I got was 6..
what might be the reason for this..??
thanks, murali
|