+ 1
What’s the ++
I keep seeing this... int x = 3 int y = ++5 int z = y + x Idk what the two ++ do
6 Respuestas
+ 5
The increment operator.
+ 4
But you can only use it on variables, not constants.
+ 3
++5 is incorrect.
+ 2
Actually your code will give error in 2nd line where u wrote ++5 . Here lvalue or expression not assignable error will occur.
You should write++x instead of
++5
First int x=3;
In next line u used pre increment
int x=++x;
Here x will be increase by 1 . And it will assign to variable y and the present value of x will be 4.
In next step
int z=y+x
Here z=4+4= which will give 8 as a output .
Hope you understood.
+ 1
++5 not do anything, but ++x do.
++ is an increment operator.
++x (pre increment) is same as x=x+1
x++ (post increment) same as x=x+1;
Difference is pre increment, first increments it's value then uses. Post increment first uses value then increments..
For more, read about incrementstion operators.
0
++ means increament by 1 and -- means decrement by 1