Write a shell script to perform mathematical operations using a select case

shell script


echo "enter two numbers "
read a b

echo "enter 1 for addition"
echo "enter 2 for sub"
echo "enter 3 for div "
echo "enter 4 for multi"
read c

case $c in

1)
expr $a + $b
;;
2)
expr $a - $b
;;
3)
expr $a / $b
;;
4)
expr $a \* $b

esac



output

enter two numbers
10 2
enter 1 for addition
enter 2 for sub
enter 3 for div
enter 4 for multi
1
12

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post