What's wrong?

Why this program doesn’t work?
Only the internal cycle works ((

i = 10
cn = 0
while cn < 3
while i < 12
puts i, cn
i += 1
end
cn += 1
end

Thanks!

Hi Komil Mum,

Your outer loop also works three times,but it’s not printing anything
because your i has reached 12 already, Please execute the below program,
you will get to understand,

i = 10
cn = 0
while cn < 3
while i < 12
puts i, cn
i += 1
end
puts i
cn += 1
end

Hi, Raja gopalan,

Thanks, I realized my mistake and corrected it))

welcome

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs