Skip to main content

Posts

99 or none ... how to arrive at it programmatically?

99 Bottles to fall....how many loops to call? This simple challenge was posed as a programming question..... If there are 99 bottles on a wall and one by one they have to be removed how many loops are required? Sample code .... int number = 99 While (number > 1) { number -=1; Console.Writeline(number.ToString() + ‘ bottles are left’); } '  &nbsp The answer : No. Change to (number >=0) This will iterate through all items.