What si the output of this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What si the output of this code?

Int x=10; Int y =(25%7) * (++x + (18%4)); System.out.print(--y);

24th May 2021, 8:09 PM
Diego Palacio
Diego Palacio - avatar
8 Answers
+ 5
Diego Palacio x is 10 so ++x will be 11 because of pre increment. So y = 4 * (11 + 2) = 52 And --y = 51 because of pre decrement Notes: modulus operator (%) returns reminder so 25 % 7 = 4 and 18 % 4 = 2
25th May 2021, 4:12 AM
A͢J
A͢J - avatar
+ 3
🅰🅹 🅐🅝🅐🅝🅣 I think you meant to say 'pre' increment and 'pre' decrement.
25th May 2021, 5:20 AM
Soumik
Soumik - avatar
+ 3
Caleb change Int to int
29th May 2021, 8:12 PM
Atul [Inactive]
+ 2
Why don't You check it in the playground..? edit : if you need explanation, read about pre increment/decrement operators....
24th May 2021, 8:15 PM
Jayakrishna 🇮🇳
+ 2
Thanks!! Now i understand :)
25th May 2021, 4:22 AM
Diego Palacio
Diego Palacio - avatar
+ 2
Soumik [Busy] Yes yes.
25th May 2021, 6:15 AM
A͢J
A͢J - avatar
24th May 2021, 8:20 PM
Brain & Bones
Brain & Bones - avatar
+ 1
Thanks :)
25th May 2021, 5:21 AM
Diego Palacio
Diego Palacio - avatar