Written by Sai Sandeep Thota on February 26, 2013 in Programming > Shell

Shell Script to Print Multiplication Table

GET ALERTS:

Get our Latest updates delivered to your mailbox!

The following program is used to print the Multiplication table of a given number. We have written two program below. One is used to print Multiplication Range upto 10 and another is used to Print Multiplication Table upto a given range. We have already written a C Program to print Multiplication Table earlier.

Here we are using a while loop to iterate. expr is used to calculate whole number arguments.

Shell Program to Print Multiplication Table

echo "Enter a Number"
read n
i=0
while [ $i -le 10 ]
do
	echo " $n x $i = `expr $n \* $i`"
	i=`expr $i + 1`
done

Shell Program to Print Multiplication Table upto Given Range

echo "Enter a Number"
read n

echo "Enter Range"
read r
i=0
while [ $i -le $r ]
do
	echo " $n x $i = `expr $n \* $i`"
	i=`expr $i + 1`
done

Output:
shell-print-multiplication-table

{ 2 comments… read them below or add one }

Udit Chugh April 29, 2015 at 12:59 am

There is a looping error!

Reply

Sai Sandeep Thota October 8, 2015 at 11:36 pm

Thank you Udit!

Reply

Leave a Comment

Previous post:

Next post: