Forum: Ruby What's wrong?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0054c6f7f4e743bbe52cb7576ec34408?d=identicon&s=25 Komil Mum (komil_m)
on 2014-04-01 15:14
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!
Cc704ce316e72af824ccd38cfa53104b?d=identicon&s=25 Raja Gopalan (arc)
on 2014-04-01 19:06
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
0054c6f7f4e743bbe52cb7576ec34408?d=identicon&s=25 Komil Mum (komil_m)
on 2014-04-01 19:53
Hi, Raja gopalan,

Thanks, I realized my mistake and corrected it))
Cc704ce316e72af824ccd38cfa53104b?d=identicon&s=25 Raja Gopalan (arc)
on 2014-04-01 19:54
welcome
This topic is locked and can not be replied to.