+ 1

Why 13 ?

Hello friends, can someone please explain me why the output of this code is 13 ? #include <iostream> using namespace std; int main() { int x=5,i; i=++x+x++; cout<<i; return 0; } thank you !

1st Jan 2017, 8:59 PM
Cihan
Cihan - avatar
2 Respostas
+ 5
x is 5 (++x) x is 6 in this operation and next +( x++) and x will be 7 AFTER the operation and next so its like ++5+6++. just check postincrements and the before increments
1st Jan 2017, 9:06 PM
Nahuel
Nahuel - avatar
+ 1
thanks 👍
1st Jan 2017, 9:17 PM
Cihan
Cihan - avatar