Skip to content

Instantly share code, notes, and snippets.

@laurenkruczyk
Last active August 29, 2015 13:56
Show Gist options
  • Save laurenkruczyk/9101617 to your computer and use it in GitHub Desktop.
Save laurenkruczyk/9101617 to your computer and use it in GitHub Desktop.
Guessing Game
x = 47
while true
puts "Guess a number between 1 and 100"
puts "Guess a number..."
number = gets.chomp.to_i
if number < 0 || number>100
puts "Invalid input, must enter a number between 1 and 100."
end
if number > x
puts "Too high, try again..."
elsif number < x
puts "Too low, try again..."
else number == x
puts "Congratulations, you've guessed the number!"
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment