Skip to content

carlosrs14/expression-evaluator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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:

./example

Example Usage

  • Example 1:

img

  • Example 2:

img

TODO

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

About

A program that evaluates arithmetic expressions using postfix notation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published