+ 1

can anyone help me?

int main() { int a = 4, b; b = a + ++a; cout<<b; return 0; } why does this code outputs 10 as b?

6th Jan 2017, 1:03 AM
Toni Mrđen
Toni Mrđen - avatar
1 Answer
+ 2
First thing it does is the ++a, so it will set a to 5 and you're left with b = a + a so b = 5 + 5 = 10
6th Jan 2017, 1:36 AM
Robobrine
Robobrine - avatar