9

I want to write a program that calculates a given math function (by the user) with specific set of values.

The user is asked to type a function, say he typed f(x)= (x^2)+3x+1 then through the program I should show the outputs of [ f(3), f(6) and f(9) ] .

The question specifically is how to fetch these x's in the typed function, then how to convert the function from a string to a double or float.

Do you have any thoughts about that ?

suppose that I'm using C , or C++

1

1 Answer 1

2

This is not an easy task, especially as operators hold precedence over others.

Have a look at some of these links so see what you're dealing with:

Equation (expression) parser with precedence?

http://en.wikipedia.org/wiki/Operator-precedence_parser

2
  • loool, I just realized how hard the task. I really feel like a stupid teenager :D . thx dude.
    – Fahd
    Aug 8, 2011 at 0:52
  • Not a bad long-term project, though, if you're willing to put some sort of commitment to it.
    – kibibyte
    Aug 8, 2011 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.