Primitive Operators question 3 | SoloLearn: Learn to code for FREE!

0

Primitive Operators question 3

What is the result of the following code? int x = 15; int y = 4; int result = x / y; System.out.println(result); R=3 //Is that real? I mean, I need to have x=12, for the (Result) R=3 //I try to do my best english guys.

6/1/2020 11:32:40 PM

JOSUE FERNANDO PEREZ PINEDA

2 Answers

New Answer

+1

Both operands for division (<x> and <y>) and also <result> are integers, hence integer division operation be at work here. 15 / 4 => 3.75, but since integers do not support fraction, the 0.75 is discarded and results in just 3.

0

For x= 12 and x =13 and x=14 and x=15 result is 3