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”

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu