Tuesday, 11 June 2013

shell script to accept a number from user and display multiplication table of given number.

Code:
echo "Multiplication Table:"
tab=1
i=1
a=10
echo "Input Number :"
read x
echo
echo "Table of $x"
for i in 1 2 3 4 5 6 7 8 9 10
do
   i=`expr $x \*  $i`
   echo $i
done


Output:
[pritam1@localhost ~]$ sh demofor.sh
Multiplication Table:
Input Number :
15

Table of 15
15
30
45
60
75
90
105
120
135
150

No comments:

Post a Comment