Need help for school

Hi guys, I have started learning C++ in school, and we had exam today in informatics class. So my question is can this be done, we learned only if we know value in one side, not in both sides, then after exam she said when it's a = --b, if a=5 and b=3 result will be 5 + (3-1) = 7 ?? is that possible

1
2
3
4
	int a = 5;
	int b = 3;

	a = --b;


and

1
2
3
4
	int a = 5;
	int b = 3;

	a = b--;
1
2
3
4
5
int a = 5;
int b = 3;

a = --b;
cout << a << endl;

Outputs -

2


1
2
3
4
5
6
int c = 5;
int d = 3;

c = d--;
	
cout << c << endl;

Outputs -

3
Last edited on
Perhaps she meant this?:

1
2
3
4
5
int a = 5;
int b = 3;

a += --b;
cout << a << endl;


Outputs -
7

Topic archived. No new replies allowed.