Write a linux shell program to perform display multiplication table

Multiplication table

Code:

clear 
echo ----------------------------------- 
echo '\tMultiplication Table' 
echo ----------------------------------- 
echo Enter table number 
read tn 
echo Enter how many rows 
read n 
i=1 
while [ $i -le $n ] 
do 
        k=$(expr $i \* $tn) 
        echo "$i * $tn = $k" 
        i=$(expr $i + 1) 
done 

Output:

Enter table number 
Enter how many rows 
1 * 6 = 6 
2 * 6 = 12 
3 * 6 = 18 
4 * 6 = 24 
5 * 6 = 30 

3 comments:

  1. I not get the output for above coding.i got the error like line 10 command no found please clear the error and correct it

    ReplyDelete
  2. there's an error there...in while condition she kept n instead of tn

    ReplyDelete

Powered by Blogger.