Languages
[Edit]
EN

Bash - how to write simple calculator?

16 points
Created by:
Wade
562

Using bash it is possible to write simple calcualtor in following way.

1. In brackets expression example

calcualtor.sh file:

#!/bin/bash

set a b operation;

echo -e "Select operation type: + - * /";
read operation;
echo "a=";
read a;
echo "b="
read b;

echo "Result:" $(($a$operation$b));

Running:

$ ./calculator.sh
Select operation type: + - * /
+
a=
3
b=
6
Result: 9

 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Bash

Bash - write simple calculator
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join