Ruby program to count the number of digits in a number
=begin
Ruby program to count the number of digits
=end
puts "Enter the number:"
num=gets.chomp.to_i
temp=num
count=0
while (temp>0)
count+=1
temp=temp/10
end
puts "#{num} has #{count} digits"
Output:
RUN 1:
Enter the number
89744
89744 has 5 digits
RUN 2:
Enter the number
8171627331
8171627331 has 10 digits
