simple calculator in bash
Calculator perform arithmetic operations like addition, subtraction, multiplication or division
code:-
echo "enter the value of a"
read a
echo "enter the value of b"
read b
echo "enter 1 for addition"
echo "enter 2 for subtraction"
echo "enter 3 for multiply"
echo "enter 4 for divison"
read c
case $c in
1)
sum= expr $a + $b
echo $sum
;;
2)
sum= expr $a - $b
echo $sum
;;
3)
sum= expr $a \* $b
echo $sum
;;
4)
sum= expr $a / $b
echo $sum
;;
esac
output:-
Post a Comment
If you have any doubts, Please let me know
Thanks!