A shell-script to accept two no. and an operator [+ – * / ] and calculate related result.

true=1

while [ $true -eq 1 ]

do

echo “Menu”

echo “1.Addition       ”

echo “2.Subtraction    ”

echo “3.Multiplication ”

echo “4.Division       ”

echo “0.Exit”

echo -e “Enter your choice::\c”

read n

echo ” ”

echo -e “Enter the first number::\c”

read n1

echo -e “Enter the second number::\c”

read n2

case $n in

1)

echo $n1 + $n2 = expr $n1 + $n2

;;

2)

echo $n1 – $n2 = expr $n1 - $n2

;;

3)

echo $n1 “*” $n2 = expr $n1 \* $n2

;;

4)

echo $n1 / $n2 = expr $n1 / $n2

;;

0)

true=0

;;

esac

done

 

OUTPUT::

 

Menu

1.Addition

2.Subtraction

3.Multiplication

4.Division

0.Exit

Enter your choice::1

Enter the first number::2

Enter the second number::5

2 + 5 = 7

Menu

1.Addition

2.Subtraction

3.Multiplication

4.Division

0.Exit

Enter your choice::0

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.