Why does 15 ÷ 4 equal 3 on this question? Is that a mistake or something the program automatically does? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why does 15 ÷ 4 equal 3 on this question? Is that a mistake or something the program automatically does?

16th Dec 2016, 4:12 AM
ベニオン 隆之介
ベニオン 隆之介 - avatar
10 Answers
+ 9
your both operands (15 and 4)are integers, that's why it return an integer value. try using 15.0 ÷4 or you could try 15÷4.0 that will give you 3.75
16th Dec 2016, 10:15 AM
Rishabh Agrawal
Rishabh Agrawal - avatar
0
Yeah it's not an error 15 divided by 4 will give you 3.••••, so just take the integer in front and ignore the decimal places
16th Dec 2016, 8:39 AM
Cloud
0
yes, you have declared an integer type so the output is integer value and it doesn't print decimal value
18th Dec 2016, 3:17 AM
Nishanth
0
but shouldn't the program give as a result 4? Doesn't it rounds the number to make it integer? 3.75 rounds to 4
8th Jan 2017, 9:07 PM
Ser Gio
Ser Gio - avatar
0
@ser gio the program is not rounding off the result instead its just taking the integer part like integer of 3.75 =3 hope this helps .
9th Jan 2017, 3:48 AM
Rishabh Agrawal
Rishabh Agrawal - avatar
0
because before u only set variables as integers
21st Jan 2017, 5:41 AM
Timzhao0205
Timzhao0205 - avatar
0
other wise use double 5; double 4; theN answer will be in decimal condition.
28th Jan 2017, 12:44 PM
INAM UR RAHMAN
INAM UR RAHMAN - avatar
0
close one eye and imagine in first grade long form division. 4 (r
5th Feb 2017, 2:56 AM
ashzole
ashzole - avatar
- 1
change integer to float
16th Dec 2016, 4:08 PM
Przemek C.
- 1
int doesnt hold decimals
20th Dec 2016, 2:01 PM
Abu Bakar Baig
Abu Bakar Baig - avatar