We shall be using Replt as our play ground environment for ruby.
Numbers in ruby can be integer or float depending on how it was specified
puts "Enter first number"
var1.to_i = get.chomps
puts "Enter second number"
var2.to_i = get.chomps
puts "your result is #{var1.to_i + var2.to_i}"
to_i:convert to string
to_f:convert to float
rand:generate random value
.time:repeat a variable by x times
20.times {rand(100)}
You can guess the answer i owe you a bottle of beer.You can experiment with more arithmetic operators like + ,/,-,%
Top comments (0)