+ 2
Why does 15 ÷ 4 equal 3 on this question? Is that a mistake or something the program automatically does?
12 Antworten
+ 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
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
0
yes, you have declared an integer type so the output is integer value and it doesn't print decimal value
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
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 .
0
because before u only set variables as integers
0
other wise use
double 5;
double 4;
theN answer will be in decimal condition.
0
close one eye and imagine in first grade long form division. 4 (r
- 1
change integer to float
- 1
int doesnt hold decimals