Like Tree1Likes
  • 1 Post By grumpy

Equation evaluator in c

This is a discussion on Equation evaluator in c within the C Programming forums, part of the General Programming Boards category; 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" ...

  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,266
    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.
    Salem likes this.
    Right 98% of the time, and don't care about the other 3%.

  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,070
    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, 04:40 PM
  2. Fast Determinant evaluator
    By jack_carver in forum C Programming
    Replies: 2
    Last Post: 12-28-2009, 07: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, 09:34 AM
  5. Expression Evaluator
    By hei in forum C Programming
    Replies: 9
    Last Post: 11-13-2001, 09:50 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21