mercredi 16 novembre 2022

Write a program which gets a number from a user and identify whether it is an Integer or a Float in ruby

I am trying this :

print " Enter Value " num = gets.chomp

also tried .kind_of? but didn't work

if num.is_a? Float
print " Number is in float "

also tried .kind_of? but didn't work

else num.is_a? Integer
print " Number is in integer "

end

Aucun commentaire:

Enregistrer un commentaire