An open API service indexing awesome lists of open source software.

https://github.com/carlosrs14/expression-evaluator

A program that evaluates arithmetic expressions using postfix notation.
https://github.com/carlosrs14/expression-evaluator

cpp evaluate-math-expressions maths postfix-evaluation postfix-notation university-assignment

Last synced: 1 day ago
JSON representation

A program that evaluates arithmetic expressions using postfix notation.

Awesome Lists containing this project

README

          

# Arithmetic Expression Evaluator

This is a C++ project that evaluates infix arithmetic expressions by converting them to postfix notation (Reverse Polish Notation) for calculation.

## Features

- Converts infix expressions to postfix.
- Evaluates the resulting postfix expression.
- Supports operators: `+`, `-`, `*`, `/`, `^`.
- Handles multi-digit and decimal numbers.
- Includes parenthesis handling.
- Error validation for invalid expressions (e.g., unbalanced parentheses, division by zero).

## How to Compile and Run

You can compile the project using g++. Make sure you have a C++ compiler compatible with C++11 or higher.

```bash
g++ -I include example.cpp src/evaluator.cpp src/posfix-evaluator.cpp -o example
```
if linux user could use:
```
compile.sh
```
Once compiled, you can run the example program:

```bash
./example
```

## Example Usage

- Example 1:

![img](assets/example1.jpg)
- Example 2:

![img](assets/example2.jpg)

## TODO
1. Add trigonometrics expressions handlers
2. Add params support
3. Add evaluation by prefix notation