New course! Every coder should learn Generative AI!
Try a free lesson+ 2
What is the difference between ++X and X++
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!
+ 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;