+ 2

[DUPLICATE] Difference between ++a and a++. Explain with example .

24th Feb 2018, 3:37 PM
Chandana Manna
Chandana Manna - avatar
3 Answers
24th Feb 2018, 3:42 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
++a is called prefix operator a++ is called postfix operator ++a ( compiler assigns +1 before reading value of the variable ) a++ ( compiler reads the value of the variable first then adds 1 )
24th Feb 2018, 4:04 PM
Saleh Ibne Omar
Saleh Ibne Omar - avatar
+ 2
int a = 0; // a is 0 int b = ++a; // a becomes 1, b is 1 int c = a++; // c is 1, a becomes 2 // a=2, b=1, c=1 a++; // a becomes 3 ++a; // a becomes 4 // no real difference between the last two statements. https://www.sololearn.com/Discuss/966359 https://www.sololearn.com/Discuss/666244 https://www.sololearn.com/Discuss/533640
24th Feb 2018, 3:47 PM
John Wells
John Wells - avatar