Ruby Program to Read an Integer Number From the User

You are currently viewing Ruby Program to Read an Integer Number From the User

Ruby program to read an integer number from the user

# Ruby program to read an integer 
# number from the user

print "Enter number: "
num = gets.chomp.to_i  

print "Number is: ",num

Output

Enter number: 12
Number is: 12

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply