0

So how does 15/4=3?? How does this below work?

Int x=15, int y=4; Int result = x / y System.out.println(result) “3”

6th Feb 2020, 2:05 PM
Bryan
6 ответов
+ 15
15 ÷ 4, specifically, is 3.75. However, because both operands in the equation are integers, the result of the division will be rounded down to an integer, which is why the answer is 3
6th Feb 2020, 2:10 PM
Faisal
Faisal - avatar
+ 3
does 4 go into 15 three times and the answer is yes Bryan 3*4=12
6th Feb 2020, 2:11 PM
BroFar
BroFar - avatar
0
my question is how does 15 divoded by 4 equal 3?
6th Feb 2020, 2:08 PM
Bryan
0
Beacuse Both operands are integer data type... (And the rule of operaters is it will give answer in same data type) if you divide 15.0/4 it will give you the exect answer what you are searching like 15.0/4.0 15(float)/4 etx there are different methods to solve it but the main thing is operator react with operends as how larg they are like int is a smal data type and float is larg data type then int if there will be two data types at the opposite sides of the operand the operand automatically change the type of small data type into large... like if i write 15/ 4.0 the program execute it like this... 15.0/4.0 then it shows the result... i hope you understand what i want to say
6th Feb 2020, 2:48 PM
waqar younis
waqar younis - avatar
0
What if u approx
10th May 2020, 7:36 AM
Paschal
Paschal - avatar
0
yes bro, because both the operands are integers, the result will also be rounded down to an integer as well.
30th Jun 2020, 6:13 PM
Ameer Haider
Ameer Haider - avatar