In: Computer Science
Hi,
/*
NOTE: I hope in this question you need a shell script for the multiplication table till 100 between 2 and 10 inclusive.
I am assuming that you can open the terminal and create a new_script.sh using vim command and put your name, and other things asked. If there is any problem you face on this, kindly revert back to me.
For your shell script code is given below you can add this to your new_script file.
*/
Code:
#reading the number
echo "Enter a Number"
read n
# Checking for the condition
if (( $n<2 || $n>10 ))
then
#If they are not between 2 and 10 inclusive then print this
echo "Please input the values between 2 and 10 inclusive."
else
# printing the multiplication table for input value upto
100;
i=1
while [ $i -le 100 ]
do
echo " $n x $i = `expr $n \* $i`"
i=`expr $i + 1`
done
fi
Input and ouput with code snippet is attached below.
Firstly,
In terminal, write
chmod +x <YOUR_SCRIPT_NAME>
then excecute
./<YOUR_SCRIPT_NAME>
.
.
.
.
.
.
.
.
.
Thanks