+ 1

What’s the ++

I keep seeing this... int x = 3 int y = ++5 int z = y + x Idk what the two ++ do

5th Oct 2020, 10:09 PM
Kevin Xuli
Kevin Xuli - avatar
6 Answers
+ 5
The increment operator.
5th Oct 2020, 10:16 PM
Sonic
Sonic - avatar
+ 4
But you can only use it on variables, not constants.
5th Oct 2020, 10:17 PM
Sonic
Sonic - avatar
+ 3
++5 is incorrect.
5th Oct 2020, 10:17 PM
Sonic
Sonic - avatar
+ 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.
6th Oct 2020, 1:10 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 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.
5th Oct 2020, 10:19 PM
Jayakrishna 🇼🇳
0
++ means increament by 1 and -- means decrement by 1
7th Oct 2020, 4:28 AM
Niteesh