Created
February 12, 2022 10:25
-
-
Save CodeMaster7000/3751b106f72816baa79945bd9b44ae75 to your computer and use it in GitHub Desktop.
A simple calculator coded in Shell which performs the 4 basic functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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