https://github.com/zikiflicky/calculator
A small and simple calculator written in C
https://github.com/zikiflicky/calculator
c c99 calculator
Last synced: about 1 month ago
JSON representation
A small and simple calculator written in C
- Host: GitHub
- URL: https://github.com/zikiflicky/calculator
- Owner: ZikiFlicky
- Created: 2021-07-21T16:47:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-22T14:59:55.000Z (almost 5 years ago)
- Last Synced: 2025-12-06T14:24:59.658Z (7 months ago)
- Topics: c, c99, calculator
- Language: C
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Calculator
This is a simple command line calculator program written in C (C99).
It can also be used as a library, if one imports just `calculator.c` and `calculator.h`.
It currently supports basic operators like + - * / () % ^.
This program was created because I wanted to think of an algorithm to do calculations, so I tried to think of my own one and came up with this.
## Build instructions
First, `git clone` the repository
### Linux or any other unix-like operating systems
#### Dependencies
* GNU make
* GCC
#### Instructions
* `cd` into the program's directory.
* Type `make`.
* Type `./calculator` to run the program
### Windows
#### Dependencies
* Visual Studio 2019
#### Instructions
* `cd` into the program's directory.
* Type `.\make`.
* Type `.\calculator` to run the program
## How it works
This calculator works by moving linearly on an array of tokens and creating a tree of nodes, that are later recursively evaluated, and at the end return a number.
### This is a node tree created from 1+2*3^4-5
```
(-)
/ \
(+) (5)
/ \
(1) (*)
/ \
(2) (^)
/ \
(3) (4)
```
It will later be evaluated recursivaly to finally return 158.