Skip to content

Instantly share code, notes, and snippets.

@CodeMaster7000
Created February 12, 2022 10:25
Show Gist options
  • Select an option

  • Save CodeMaster7000/3751b106f72816baa79945bd9b44ae75 to your computer and use it in GitHub Desktop.

Select an option

Save CodeMaster7000/3751b106f72816baa79945bd9b44ae75 to your computer and use it in GitHub Desktop.
A simple calculator coded in Shell which performs the 4 basic functions.
echo "Enter two numbers:"
read a
read b
echo "Enter choice:"
echo "1. Addition"
echo "2. Subtraction"
echo "3. Multiplication"
echo "4. Division"
read ch
case $ch in
1)res=`echo $a + $b | bc`
;;
2)res=`echo $a - $b | bc`
;;
3)res=`echo $a \* $b | bc`
;;
4)res=`echo "scale=2; $a / $b" | bc`
;;
esac
echo "Result : $res"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment