+ 2

Why the output is 1 why don't it shows 0 as it's output?

https://code.sololearn.com/cl2elQ8cAIg8/?ref=app

21st Jun 2017, 3:46 AM
Tushar
Tushar - avatar
4 Respuestas
+ 16
++x gives ++0 ie 1 plus --x gives --1 ie 0 1+0 is 1 Alternatively you can go like this a=++x. //1 b=--x. //0 Output.. a+b //1+0=1 Most probably it goes like this only..
21st Jun 2017, 3:54 AM
Frost
Frost - avatar
+ 8
Keep in mind what @Rrestoring faith said. There is no single way to determine the output, because compilers and compilers differ and may produce different results, even in one language.
21st Jun 2017, 3:58 AM
Hatsy Rei
Hatsy Rei - avatar
+ 7
Java works with these a little differently from C++ if that's what's causing your confusion. In C++ this code would give 0. In Java, what @Frost said.
21st Jun 2017, 3:56 AM
Rrestoring faith
Rrestoring faith - avatar
+ 1
Thank you
21st Jun 2017, 4:19 AM
Tushar
Tushar - avatar