New course! Every coder should learn Generative AI!
Try a free lesson+ 3
How to input a floating point number in Ruby
2 Answers
+ 4
This works:
var = gets.chomp.to_f
print var
just add "to_f" (to float) function and viola! you can even operate with other floats.
+ 2
This works too:
x=gets.to_f
puts x