Skip to content

Commit

Permalink
calculator in bash
Browse files Browse the repository at this point in the history
  • Loading branch information
dee-mee committed Apr 3, 2024
1 parent df183de commit 511c1f2
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions script7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

##This script illustrates how to make a calculator using bash

clear

sum=0
i="y"

echo "Enter first no: "
read n1
echo "Enter second no: "
read n2

while [ $i = "y" ]
do
echo "1. Addition"
echo "2. Subtraction"
echo "3. Multiplication"
echo "4. Division"
read op

case $op in
1) sum= expr $n1 + $n2
echo "sum = "$sum;;
2) sum= expr $n1 - $n2
echo "Sub = "$sum;;
3) sum= expr $n1 \* $n2
echo "Mult = "$sum;;
4) sum= expr $n1 / $n2
echo "Div = "$sum;;
*)echo "Invalid choice";;

esac

echo "Do you want to continue (Y/n))? "
read i
if [ $i != "y" ]
then
exit
fi
done

0 comments on commit 511c1f2

Please sign in to comment.