Monday, 9 April 2018

Shell script to display a multiplication table

#Script to display a multiplication table n times
echo "Enter the value for m and n"
read m n
for((i=1;i<=n;i++))
do
 echo $i '*' $m = `expr $i \* $m`
done



OUTPUT
Safi>bash mult.sh
Enter the value for m and n
5 10
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50

No comments:

Post a Comment