12,074,771 members (57,985 online)
Rate this:
See more:
I need a code which can solve the equations like this :-
`56*78+(78/8)`
In this we know that brackets must be solved first and then divide/multiply and then add/subtract.
So, i need a code for solving this kind of equations which contains multiple operators in single line.

Thnks
Posted 17-Jul-12 3:24am
Edited 17-Jul-12 3:37am
v2

Rate this:

## Solution 1

I think this is what you are looking for

Expression Evaluator for C# based on Expression Tree[^]

Just do the following using sample code in the above article:

```IParser par = new ExpParser();
ExpEvaluator eu = new ExpEvaluator(par);
string expresion = "56*78+(78/8)"
eu.SetExpression(expresion);
double res =eu.Evaluate();```
Rate this:

## Solution 2

You should use google to search for "mathematical expression parser". There are thousands of results. Here are some promising ones:
Mathematical Expression Parser Using Recursive Descent Parsing[^]
a Tiny Parser Generator v1.2[^]
Simple(x) Numerical Formula Parser[^]
Expression Evaluator for C# based on Expression Tree[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 571 ProgramFOX 290 Dave Kreskowiak 240 CHill60 160 Richard MacCutchan 159
 Dave Kreskowiak 2,746 OriginalGriff 2,580 Richard MacCutchan 1,834 CPallini 1,507 CHill60 1,379

Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 17 Jul 2012