3

I am writing a program in c++ that shows if an expression (example 98+56*(4+7) < 7-6*6) is true or false.. The expression will be taken as an input from the user..

Is there any function that I can use for this?

Vincent Savard
  • 34,979
  • 10
  • 68
  • 73
Adela
  • 35
  • 1
  • 8

2 Answers2

4

You need math expression evaluator.

You can try this library: https://fastmathparser.codeplex.com/

In the link you'll find a sample code.

You can find an algo in this link: Evaluating arithmetic expressions from string in C++

Community
  • 1
  • 1
p.magalhaes
  • 7,595
  • 10
  • 53
  • 108
1

No, but implementing the Shunting Yard Algorithm is fairly easy if you are reasonably competent at programming.

I know link only answers are abhorred but here is the link on wikipedia (which is unlikely to disappear soon) and is actually quite good.

graham.reeds
  • 16,230
  • 17
  • 74
  • 137