Created
November 2, 2011 12:36
-
-
Save sriki77/1333512 to your computer and use it in GitHub Desktop.
Ruby Day 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1. Print Hello World | |
puts "Hello World." | |
#2. Index of "Ruby" | |
puts "Hello Ruby".index("Ruby") | |
#3. Name 10 times | |
puts "Srikanth#{$/}" * 10 | |
#4. Sentence with number change | |
(1..10).each do |i| puts "This is sentence number #{i}" end | |
#5.Rand Num Guess | |
num_selected=rand(10); | |
begin | |
print "Enter Your Guess: " | |
num_guessed=gets.to_i | |
puts "Guess is Higher" if num_guessed > num_selected | |
puts "Guess is Lower" if num_guessed < num_selected | |
puts "Guess is Correct!" if num_guessed == num_selected | |
end while num_selected != num_guessed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment