Thread: Equation evaluator in c

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    1

    Equation evaluator in c

    I need to create an equation evaluator in c. Purpose is, i have an equation in string(char[]) form like "((2+3)log(165))^2" and need to evalute this in c. i cannot use any external c libraries (i can use math.h).

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    What, you think someone is going to write code for that, just for kicks, eh?

    You might want to think again. This is not a free code factory.

    Doing this is of only moderate difficulty, but it does take some effort on your part. Or paying a professional the going rate for their time to do it for you, in which case you might want to post here.

    Decent programmers don't come all that cheap though.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Stoned Witch Barney McGrew's Avatar
    Join Date
    Oct 2012
    Location
    astaylea
    Posts
    420
    Quote Originally Posted by flytokhushi View Post
    Purpose is, i have an equation in string(char[]) form like "((2+3)log(165))^2" ...
    That isn't an equation.

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by flytokhushi View Post
    I need to create an equation evaluator in c. Purpose is, i have an equation in string(char[]) form like "((2+3)log(165))^2" and need to evalute this in c. i cannot use any external c libraries (i can use math.h).
    In the book The C Programming Language by Brian Kernighan and Dennis Ritchie, there is a complete example of a program to evaluate expressions of this sort in RPN-notation. You could use that as a starting point. If you have a function which evaluates RPN expressions, then all that is needed is to convert your input expression into RPN.

    For example, the expression you mentioned, pow(((2+3)*log(165)),2) could be written as follows in RPN:

    2 3 + 165 log * 2 pow

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic RPN expression evaluator
    By manasij7479 in forum C++ Programming
    Replies: 10
    Last Post: 02-03-2011, 05:40 PM
  2. Fast Determinant evaluator
    By jack_carver in forum C Programming
    Replies: 2
    Last Post: 12-28-2009, 08:42 PM
  3. Grade Evaluator
    By Takumi8374 in forum C Programming
    Replies: 5
    Last Post: 05-24-2005, 12:01 PM
  4. Expression Evaluator Contest
    By Stack Overflow in forum Contests Board
    Replies: 20
    Last Post: 03-29-2005, 10:34 AM
  5. Expression Evaluator
    By hei in forum C Programming
    Replies: 9
    Last Post: 11-13-2001, 10:50 AM

Tags for this Thread