Pre/Post Incre/Drecement

Hi huys,any good idea on how to understand it?

my own answer != compiler output ;-(

What i did to ans1 was:
ans1= 21 + 21 - 12 - 11;
ans2= (10 - 8%4) + 20 + 13;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #include<iostream>

using namespace std;

int main()
{
	int a=20,b=9,c=12;
	int ans1,ans2;
	ans1=++a + ++a - c-- - --c;
	ans2=((++b - --b)%4) + a++ + ++c;
	cout<<"Ans1:"<<ans1<<endl;
	cout<<"Ans2:"<<ans2<<endl;



	system("pause");
	return 0;
}
Well, that's because you are invoking undefined behavior. You cannot modify the same variable multiple times between sequence points.
doesnt help me much,dat link but at least thks for ur reply ;-)
Topic archived. No new replies allowed.