Wednesday, 22 July 2015

Infinite Arithmetic Precision Shell Script/arithmetic operations

#!/bin/bash

addition()
{
sum=$(echo $a + $b | bc)
echo $sum
}
subtraction()
{
sum=$(echo $a - $b | bc)
echo $sum
}
multiplication()
{
sum=$(echo $a \* $b | bc)
echo $sum
}
division()
{
sum=$(echo $a / $b | bc)
echo $sum
}
menu()
{
echo "Enter any Two Numbers:"
read  a b
echo $a $b
}
menu
addition $a $b
subtraction $a $b
multiplication $a $b
division $a $b

No comments:

Post a Comment