Showing posts with label Number of digits in a number. Show all posts
Showing posts with label Number of digits in a number. Show all posts

Shell programming - Number of digits in a number

# Shell programming
# Number of digits in a number

echo -n "Enter a number : "
read n

i=1
while [ $n -gt 10 ]
do
n=`expr $n / 10`
i=`expr $i + 1`
done

echo “Number of digits is $i”