4. Write a shell script to print the multiplication table of given number up to a given range.
Program
# Write a shell script to print the multiplication table of given number
# up to a given range.
echo "Enter NO.:"
read no
echo "Enter range:"
read r
i=1
while test $i -le $r #starts with 1 to given range
do
temp=`expr $no \* $i`
echo "$no * $i = $temp"
i=`expr $i + 1`
done
Output
Enter NO.:
5
Enter range:
6
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
Enter NO.:
15
Enter range:
4
15 * 1 = 15
15 * 2 = 30
15 * 3 = 45
15 * 4 = 60