+ 3

Can someone breakdown what happens in this code cuz i'm a little confused here

#include <iostream> using namespace std; int main(){ int i = 0; i = ++i + ++i; cout << i; // outputs 4 return 0; }

7th Sep 2017, 12:45 PM
Sanoj Silva
Sanoj Silva - avatar
2 Respuestas
+ 5
https://code.sololearn.com/c41753l2UDU3/?ref=app i =0;//default i = ++i + ++i // i preincremented by 1 twice due to this ++i i = 2 + 2// so now after adding i twice it becomes 4 i = 4//
7th Sep 2017, 12:51 PM
Lord Krishna
Lord Krishna - avatar
+ 4
hey thanku somuch yeah and it shoud output 4 my mistake @Lord Krishna
7th Sep 2017, 12:54 PM
Sanoj Silva
Sanoj Silva - avatar