0

what's the difference between x++ and ++x

30th Dec 2016, 3:27 PM
tinega gideon
tinega gideon - avatar
3 Answers
+ 2
x++ (x sufix) = you first assign, then increment. ++x (x prefix) = you first increment, then assign.
30th Dec 2016, 3:30 PM
BaHaMuT
BaHaMuT - avatar
0
The former is called pre-increment and later is called post-increment. ++x means first increase the value of x by 1 and then use it. whereas x++ means first use the value of x and then increment it's value by 1. Note: both printf statements are separate not one after other. https://www.codecademy.com/en/forum_questions/514995a07272221a5b001f32 Now x++ means Increment x after this line and ++x means Increment x before this line. With i++, it's called postincrement, and the value is used in whatever context then incremented; ++i is preincrement increments the value first and then uses it in context
7th Oct 2018, 12:33 PM
deepak sharma
deepak sharma - avatar