# equation solving

This is a discussion on equation solving within the C Programming forums, part of the General Programming Boards category; Hey y'all, I'm designing a calculator application and know how to do pretty much everything that the calulator needs to ...

1. ## equation solving

Hey y'all,
I'm designing a calculator application and know how to do pretty much everything that the calulator needs to do except for a couple things, but once I get one figured out I should be able to get the other. I need to know how to take an equation as input and parse the equation, evaluate, and give the answer. I also need to know how to take an equation as input and graph the equation on the screen. An answer to either or both of these questions would be much appreciated. Nothing real fancy, just something to get me pointed in the right direction would be fine. Thanks alot.

-AJ

2. Calculator? I asume u would use the functions in math.h.

if the operators and numbers of the equation are seperated by spaces that you can use strtok to get each individual character and parse them.

Anyway it's just a suggestion hope it helps.

3. ## Re: equation solving

hi dear,
you can use a stack to get the user to enter the entire string as a character type in infix notation with parenythesis & then solce the entire string using push & pop functions of the stack according to their precedence

this is only a suggesition.
sk_agarwals

4. You can put the equation in a tree and then calculate the result by traversing through the tree.

5. You can use scripts.

When the user presses + on the calc you would do an add. Token for it might be <add v1,v2> or whatever. If you used a small scripting language you could solve very complex equations on your calc.

6. So you mean actually create my own small language designed specifically for evaluating the equations?

-AJ

7. Just evaluating an expression isn't too hard but if you mean solve x in

5 = 4 + x + (3 * x)
looks a bit harder.