Typo in this question? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Typo in this question?

The question gave this code and asked for an answer: int x = 15; int y = 4; int result = x / y; System.out.println(result); It only accepts on number, yet this isn't an integer. Appearently it was 3? Last time I checked 4*3 is 12 not 15. Is this something i'm missing or is it a typo?

2nd Jul 2017, 9:56 PM
nitro ignika
nitro ignika - avatar
2 ответов
+ 2
it's Integer Division which always rounds down.. so the correct answer is 15/4 = 3.75 -> 3
2nd Jul 2017, 10:14 PM
Aisinthalor
Aisinthalor - avatar
+ 2
whoops there was someone a little bit faster :D
2nd Jul 2017, 10:16 PM
Aisinthalor
Aisinthalor - avatar