+ 3

[There's not] an Error in tutorial question!

What is the output of this code? a = 25 b = 8 x = a/b puts x+b Value a should be 24. the answer is 11 . Just saying!! :)

24th Jan 2018, 2:11 PM
Clare
Clare - avatar
8 odpowiedzi
+ 8
You're dealing with an integer, or whole number, so there's no decimal points, which is why the equation (X = 25 ÷ 8) works. 25 ÷ 8 = 3.125, but since no decimals are allowed, it becomes 3. Now it's X+B, and X = 3, and B = 8 So X+B is 3 + 8 which equals 11.
24th Jan 2018, 5:02 AM
reinadf
reinadf - avatar
+ 10
no, it is ok, these numbers are integers so 25 / 8 is also 3 like 24 / 3 is 3...
24th Jan 2018, 1:28 AM
Vukan
Vukan - avatar
+ 3
its no error buddy . its simple division ( the one we did in lower classes without any decimal ). but its good that u clarified it. 😀😀😀
24th Jan 2018, 2:08 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 2
25/8=3.125 I assume that you are using int so the .125 is ‘thrown’ away. And 3 + 8 = 11
24th Jan 2018, 1:27 AM
Dnyl
+ 2
Oh god. Good to clear that up- we're dealing with integers.... OK then (rewind!!!) :)
24th Jan 2018, 2:10 PM
Clare
Clare - avatar
+ 1
Oh I see what happend. You did the division but multiplied instead of adding the 8.
24th Jan 2018, 1:31 AM
Dnyl
0
I ask...why you use 24 in this code
24th Jan 2018, 3:54 PM
Lovely Jay
Lovely Jay - avatar