HELP! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

HELP!

What procedures should I perform to complete this? What is the output of this code? a = 8 a /= 3 puts 4%a

1st Jan 2020, 1:41 AM
Lautaro Tomás Ruiz
Lautaro Tomás Ruiz - avatar
1 Answer
+ 4
The output of the code is 0. This is because a, which is 8, divided by 3 returns 2(8 / 3 = 2 with a remainder of 2), which is the whole number after dividing. We then print to the console the modular value of 4 divided by a(now 2), which returns 0 because there's a remainder of 0 after dividing 4 by 2. By the way, I suggest typing such simple problems in the Code Playground, to see the result without having to ask.
1st Jan 2020, 1:46 AM
Jianmin Chen
Jianmin Chen - avatar