Code In Tech - The Ultimate World of Computer Technology

Thursday 7 June 2012

Shell script for multiplication table

SOURCE CODE:

echo "Enter the number:"
read i
echo "$i table"
j=1
while [ $i -le 10 ]
do
l=`expr $j \* $j = $l`
echo "$j *$i = $l"
j=`expr $j + 1`
done

OUTPUT:

Enter the number:
2
2 table
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 =20

No comments :

Post a Comment