https://github.com/tmpstpdwn/simplemathrepl
A simple command-line math evaluator written in C
https://github.com/tmpstpdwn/simplemathrepl
beginner c c-beginner c-programming-language evaluator io linux math math-expression-evaluator parse repl shunting-yard-algorithm unix
Last synced: 3 months ago
JSON representation
A simple command-line math evaluator written in C
- Host: GitHub
- URL: https://github.com/tmpstpdwn/simplemathrepl
- Owner: tmpstpdwn
- License: gpl-3.0
- Created: 2025-04-26T13:11:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-12T12:17:28.000Z (11 months ago)
- Last Synced: 2025-12-26T07:58:53.547Z (6 months ago)
- Topics: beginner, c, c-beginner, c-programming-language, evaluator, io, linux, math, math-expression-evaluator, parse, repl, shunting-yard-algorithm, unix
- Language: C
- Homepage:
- Size: 67.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleMathREPL
A simple command-line math evaluator written in C. This program supports basic arithmetic operations, operator precedence, parentheses, and variables. It allows you to evaluate mathematical expressions interactively.
## Features
- **Basic Arithmetic**: Supports `+`, `-`, `*`, and `/` operations.
- **Operator Precedence**: Follows standard operator precedence (multiplication and division are evaluated before addition and subtraction).
- **Parentheses**: Supports parentheses `()` for grouping expressions and controlling the evaluation order.
- **Variables**: You can store results in variables (single-letter variables, `a-z`), and use them in subsequent expressions.
## Usage
1. **Run the Program**:
Simply compile and run the program. It will prompt you for input.
```bash
make
./smrepl
```
2. **Basic Operations**:
You can enter expressions like:
```bash
$ 3 + 5 * 2
= 13
$ (3 + 5) * 2
= 16
```
3. **Variables**:
You can assign values to variables using the > operator.
Variables are single letters from a to z.
All 26 variables are initiated to 0.
Example:
```bash
$ 1 + 2 > x # Assigns the result of the expression to variable 'x'
= 3
$ 3 + 5 > y
= 8
$ x + y
= 11
```
5. **Exit**:
To exit the program, use Ctrl+D.
## LICENSE
This project is licensed under GPL3 [LICENSE](LICENSE).