Write the command to perform all the arithmetic operations using basic calculator.
Answers
Answer:
expr
Explanation:
Command to perform all the arithmetic operations using basic calculator.
Assuming the question is for Unix OS.
expr command is for this operation.
For minus, division, plus and modules use the signs as - , / , + , %.
However it works slightly differently for multiplication. Here we need to use
\* operator.
$expr $a \* $b
Another option is to use let operator. This works on unary operator.
$ let c=++c
Answer:
bc command is used for command line calculator. This is same as basic calculator and you can perform all the functions that a basic calculator does. Here are some of the examples of the same.
Input : $ echo ""12+4"" | bc
Output : 16
Input : $ echo ""6^5"" | bc
Output : 30
Input:
$ x=`echo ""12+5"" | bc`
$ echo $x
Output:17
Input: $ echo ""var=10;var"" | bc
Output: 10
Input:
$ x=`echo ""var=500;var%=7;var"" | bc`
$ echo $x
Output:3
Input: $ echo ""var=10;++var"" | bc
Output: 11