- 1

Increments

13th Mar 2017, 2:23 PM
Emanuel Dajti
Emanuel Dajti - avatar
3 Respuestas
0
#include <iostream> using namespace std; int main(){ int a = 2; int b = a++ + a++; cout << a << endl; cout << b; }
13th Mar 2017, 2:23 PM
Emanuel Dajti
Emanuel Dajti - avatar
0
Why will the value of "a" be 4 And the value of b 5 ?
13th Mar 2017, 2:24 PM
Emanuel Dajti
Emanuel Dajti - avatar
0
a++ value of a is used then incremented ++a value of a is incremented then used so.. b=2+3. =5. ( value of a becomes 3 after first increment ) and as a is incremented two times a=4
13th Mar 2017, 4:59 PM
onkar