Shell Programming - Arithmetic operations

# Shell Programming
# Arithmetic Operations

echo "Menu"
echo "1 - Addition"
echo "2 - Subtraction"
echo "3 - Multiplication"
echo "4 - Division"

echo -n "Enter your choice : "
read n

echo -n "Enter the numbers : "
read a b

case $n in
1) echo "Sum of $a and $b is `expr $a + $b`";;
2) echo "Difference of $a and $b is `expr $a - $b`";;
3) echo "Product of $a and $b is `expr $a \* $b`";;
4) echo "Division of $a by $b is `expr $a / $b`";;
*) echo "Invalid choice";;
esac

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu