+ 1

What does ++ , -- mean in programming language C++

C++

30th Sep 2017, 5:21 PM
Jnr Bill Gates
Jnr Bill Gates - avatar
9 ответов
+ 15
++ is the increment operator. It increment of 1 the variable. x++; is equivalent to x = x + 1; or to x += 1; The increment operator can be written before (pre - increment) or after the variable (post-increment). In case of a statement with only the increment operator, there is no difference among pre and post: x++; is equivalent to ++x; But in more complex statements there is difference: y = x++; is NOT equivalent to y = ++x; y = ++x; is equivalent to the following 2 statements: x = x +1; y = x; y = x++; instead is equivalent to the 2 statements: y = x; x = x + 1; The 2 statements are the same, but they are executed in opposite order (the value of x is the same, while the value of y is different). The same apply for decrement operator --.
1st Oct 2017, 7:51 AM
Daniele Gaito
Daniele Gaito - avatar
30th Sep 2017, 5:35 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
-- decrement ++increment int x=6,y; y=x++; \\output x=7;y=6; y=++x; \\output x=7; y=7; the same applies to the decrementation..
30th Sep 2017, 6:37 PM
love
love - avatar
+ 1
++ and -- are the short hands of +1 and -1 respectively. for example x=x+1/x+=1 or x=x-1/x-=1 instead we could write as x++ and x-- respectively
30th Sep 2017, 5:34 PM
Rohith Palakkeel
Rohith Palakkeel - avatar
+ 1
--=Decrement ++=Increment r-- means r=r-1 r++ means r=r+1
30th Sep 2017, 5:49 PM
Rishita
Rishita - avatar
+ 1
Increment is ++ Decrement is -- There is also prefix and post fix Prefix increment ++x Prefix decrement --x Postfix increment x++ Postfix decrement x-- In prefix, the value is increased or decreases before performing an operation. In postfix, the operation is performed with the initial value before the decrement or increment Example Int X= 5; Int Y= ++X; System.out.println(y); } //output is 6 Example Int x = 5; Int y = x++; System.out.println(y); } //output is 5
1st Oct 2017, 8:38 AM
Stellamaris
Stellamaris - avatar
0
ok
30th Sep 2017, 5:49 PM
Jnr Bill Gates
Jnr Bill Gates - avatar
0
Pre-increment:++X Post-increment:X++ Pre-decrement:--X Post-decrement:X--
2nd Oct 2017, 1:52 AM
Ranjit Gowda V R
Ranjit Gowda V R - avatar
0
Hi
8th Mar 2020, 9:23 AM
Akwarandu Ifeanyichukwu ThankGod
Akwarandu Ifeanyichukwu ThankGod - avatar