ARITHMETIC OPERATION

SOURCE CODE:
echo "Enter the values"
read i
read j
echo "Enter 1 for addition"
echo "Enter 2 for subtraction"
echo "Enter 3 for multiplication"
echo "Enter 4 for division"
echo "enter choice"
read a
x=1
y=2
z=3
m=4
if [ $a -eq $x ]
then
l=`expr $i + $j`
echo “ The addition is ”
echo $l
elif [ $a -eq $y ]
then
k=`expr $i - $j`
echo “ The subtraction is ”
echo $k
elif [ $a -eq $z ]
then
p=`expr $i \* $j`
echo “ The multipliction is ”
echo $p
elif [ $a -eq $m ]
then
s=`expr $i / $j`
echo “ The division is ”
echo $s
fi

OUTPUT:
[examuser35@localhost Jebastin]$ sh arithmetic.sh
Enter the values
3
5
Enter 1 for addition
Enter 2 for subtraction
Enter 3 for multiplication
Enter 4 for division
Enter choice
3
The multiplication is
15
Previous
Next Post »

If you still didn't find what you're looking for, you can search this website below: