What is the difference between ++X and X++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between ++X and X++

14th Sep 2019, 3:54 PM
vasundhara r
vasundhara r - avatar
2 Answers
+ 1
both are use to increment x by 1.. the difference is; ++x is pre-incremented(that is, adds 1 to x before using it), x++ is post-incremented(that is, uses the variable and then adds 1). . hope that helps!
14th Sep 2019, 4:21 PM
DOJ
DOJ - avatar
+ 1
They are both add 1 to x but the diffrence is that: Example: Void dosomething(int x){ X++; } int x=4; dosomething(x); Console.writeline(x); Output: 4; And if i would change x++ to ++x the output woyld be 5;
14th Sep 2019, 4:22 PM
KfirWe
KfirWe - avatar