I need a code which can solve the equations like this :-
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 :)

Recommended Answers

All 4 Replies

I'm not a C programmer but the equasion should be something like:

variable1 = 78/8;
variable2 = (56*78) + variable1;

Deceptikon is right though something as simple as that shouldn't be hard to find on Google

I need a code which can solve the equations like this :-

Nobody is going to just give you the code. To do it properly would involve writing essentially a tiny compiler for mathematical expressions where you tokenize the line, convert it into an expression tree, and parse that tree to evaluate the result. It's not especially difficult, but not trivial either.

A google search will work wonders.

you can do it like this
d=a*b +c;

This is simple you can solve it using stacks .You must have heard about postfix and infix notation .You just convert into postfix and then solve it using a stack.
you should get the equation in the form of an array.Hope it will help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.