i stuck in a quiz, pls help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

i stuck in a quiz, pls help

What is the result of the following code? int x = 15; int y = 4; int result = x / y; System.out.println(result);

13th Sep 2019, 5:44 AM
molo
molo - avatar
2 Answers
+ 2
It's 3 Because 15 / 4 = 3 rem 3 but it's rounded down
13th Sep 2019, 5:51 AM
Qudusayo
Qudusayo - avatar
0
Since both data types are integer, you will get an integer result instead of floating point number. If you wanna get that desired number, use 15 / 4.0 or 15.0 / 4.0
13th Sep 2019, 8:54 AM
Talha Altınel (The Last Sith Lord)
Talha Altınel (The Last Sith Lord) - avatar