+ 5

What is the output of this code?

x = 8 x /= 2 y = 1 x.times {y+=2} puts y

10th Jan 2018, 9:24 AM
h a w k
8 Answers
+ 23
9
10th Jan 2018, 9:26 AM
Nithiwat
Nithiwat - avatar
+ 2
I figure it out. thanks
10th Jan 2018, 9:32 AM
h a w k
+ 2
🔮Final Answer 3/3đŸ”” but first read process x=8 x/=2 y=1 x.times{y+=2} puts y ................................... I understand this: x=4 4.times{1+2} puts y Correct Output Answer 9
23rd Jan 2018, 7:32 PM
Nestor Velez
Nestor Velez - avatar
+ 2
i think ans is 9
14th Mar 2018, 4:00 AM
Alexey Belousov
Alexey Belousov - avatar
+ 1
First the variable x is divided by 2, giving us a result of 2, then we put to variable y with 1. Finally we make a loop with 4 iterations, (4*2) + 1 from y = 9
14th Mar 2018, 4:59 PM
David Rueda đŸ‡Ș🇾
David Rueda  đŸ‡Ș🇾 - avatar
+ 1
9
30th Mar 2018, 6:17 AM
amrendra singh rathore
amrendra singh rathore - avatar
0
Hi. X =8 X=4 Y=1 4 times 1+=2 4*2+1=9 Final result is 9
28th Mar 2018, 2:13 PM
David Rueda đŸ‡Ș🇾
David Rueda  đŸ‡Ș🇾 - avatar
0
I am sorry but i don’t understand why the output is 9. To me it would be 12. I get all the variable right but why do we 4 times 1+=2 to 4*2+1? đŸ€·â€â™‚ïž
4th Oct 2020, 2:22 PM
Timothy Cohen
Timothy Cohen - avatar