Languages
[Edit]
EN

Bash - how to write simple calculator?

13 points
Created by:
AnnLen
12430

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

 

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