Skip to content

A C++ project that evaluates mathematical expressions using infix to postfix conversion and stack-based evaluatio

Notifications You must be signed in to change notification settings

Raghavendrajonnala2007/expression-evaluator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฎ Expression Evaluator in C++

This is a C++ project that takes a mathematical infix expression (like 2 + 3 * (4 - 1)) and:

  1. Converts it to postfix (Reverse Polish Notation) format
  2. Evaluates the postfix expression using a stack

It's basically how calculators or compilers handle expressions behind the scenes.


๐Ÿš€ Features

  • ๐Ÿ”„ Infix โžก๏ธ Postfix conversion
  • ๐Ÿง  Stack-based RPN evaluation
  • โœ๏ธ Handles brackets and operator precedence
  • โš™๏ธ Uses STL (stack, vector, string)
  • ๐Ÿ’ก Modular code with clean function design

๐Ÿ“ธ Example

Input Expression: 2 + 2 * (1 * 2 - 4 / 2) * 1

Postfix (RPN): 2 2 1 2 * 4 2 / - * 1 * +

Evaluation Result: 0


๐Ÿ› ๏ธ How to Run

๐Ÿ”ง Compile:

g++ src/main.cpp -o evaluator

./evaluator
expression-evaluator/
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ src/
    โ””โ”€โ”€ main.cpp

About

A C++ project that evaluates mathematical expressions using infix to postfix conversion and stack-based evaluatio

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages