To generate Random number in ruby we will use rand() method #input upper and lower limits #generate and print the random numbers Output Enter Max number
puts "Enter Max number"
max=gets.chomp.to_i
puts "Enter Min number"
min=gets.chomp.to_i
#between the given lower and upper limit
puts "The random numbers are..."
puts rand(min..max)
puts rand(min..max)
puts rand(min..max)
puts rand(min..max)
puts rand(min..max)
40
Enter Min number
20
The random numbers are...
28
26
22
37
31
Program to Print Triangle of Numbers in Ruby
What's the difference between a lambda, a block and a proc?
How to Sort Array in Ruby?
Ruby program to generate random numbers
Ruby program to check whether the given number is palindrome
how to create an array with Array.[](*args) in Ruby ?
Ruby program to print an array
How to Get Input with Gets in Ruby
How to create two dimensional array in ruby?
Ruby program to check whether the given number is Armstrong
Creating Array with Array.new(size, obj) in Ruby
What are #method_missing and #send? Why are they useful?
What are the various Ruby runtimes, and how are they different?
Ruby program to check whether the given number is prime or not
How to add/remove elements to Array in Ruby?
How to shuffle an array in Ruby?
What are some of your favorite gems? What are their alternatives?
How to get index of array element in Ruby
How to Replace array elements in Ruby?
Ruby program to print Fibonacci series
Ruby program to Calculate the factorial of given number
Ruby program to reverse a string
Ruby program to add two integer numbers