+ 1
What is the difference about --x and x-- ? I'm still confused about it, especialy when a question pop up like this --x++ 😂😂
8 ответов
+ 18
a nice idiom to this topic, from oma falk (sometimes batman):
what you see first, do first
this one helps me, to manage ++x and x++
+ 10
Remember lessons have many comments, you can find answers to many of your problems and much more interesting things! :)
+ 6
@tooselfish is right
x++ use the value of x and then incremnet by 1
++x incremnet by 1 and then use the value of x
i never really use x++ to be fair.
+ 5
Okay, that's a very basic question. You should have cleared that out before started learning programming.
But here's it...
Example for Prefix Operators ...
int x=2; // x is declared value 2
s = ++x; // ++x means the value of x is increased now and s will be equal to 3 now onwards
Exampke for Postfix Operators...
int x=2; // x equals 2 now
s = x++; // postfix operator means that here in the line x will use it's original value but now onwards after this line, x's value will be increased to 3. so s=2, but now x=3.
+ 4
If x=10
y=x++
y is 10
x is 11
y=--x
y is 9
x is 9
y=++x--
y is 11
x is 10
Symbols before are seen by y.
Symbols after only increase/decrease the x after y is assigned x's original value.
So y=--x++
assigns the value of x-1 and x stays the same.