Thursday, June 02, 2011

Calculation

#!/bin/sh
if [ $# -ne 2 ]
then
echo "Please Enter 2 Numbers !!! "
else
echo "Enter First Number : "
read a
echo "Enter Second Number : "
read b
c=echo "Enter The Operation You want To Calculate : "
echo "+ For Addition"
echo "- For Subtraction"
echo "* For Multiplication"
echo "/ For Division"
case $d in
+) c=$( expr $a + $b )
-) c=$( expr $a - $b )
*) c=$( expr $a \* $b )
/) c=$( expr $a / $b )
esac
echo "The Answer is : " $c
exit 0

No comments:

Post a Comment