CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2001
    Location
    India
    Posts
    145

    Help in Expression Evaluation

    Hi,
    I am trying to write a code for evaluating a expression for ex :- (((a=b)&&(b<=c))|| (f>=g))

    I have to execute this expression and find out if it returns a True or False, so that i can call the "Then" Statement or the "Else" Statement accordingly. I am really cloueless abt how to do this , does anyone, have a code sample or the code itself or any suggestions on how to get going with this????.

    thanx
    Muthu

  2. #2
    Join Date
    Jun 2002
    Location
    Florida
    Posts
    32
    Code:
    if( (((a=b)&&(b<=c))|| (f>=g)) )
    {
       /*true*/
    }
    else
    {
       /*false*/
    }
    That?

  3. #3
    Join Date
    Jun 2002
    Posts
    224
    You’ll find an excellent example in Bjarne Stroustrup’s book <The C++ Programming Language>.
    Mr. Stroustrup explains in chapter <3.1 A Desk Calculator> how to parse an expression.

    Good luck!


    ZDF

    What is good is twice as good if it's simple.
    "Make it simple" is a complex task.

  4. #4
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    I think Wake's reply should have been

    Code:
    if( (((a==b)&&(b<=c))|| (f>=g)) )
    {
       /*true*/
    }
    else
    {
       /*false*/
    }
    Succinct is verbose for terse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured