Thread: How to solve expressions like this

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    5

    How to solve expressions like this

    c= (a,b)+(b,c)-(a,b)*(c,b);
    if a,b,c are respectively 1,2,3

  2. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    What is the comma suppose to do here? Is this a algebraic expression?

    If so you could just do:

    c= (a*b)+(b*c)-(a*b)*(c*b);

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    5
    Yes this is an algebric expression if it was like (a*b) i know how to solve that
    but dunno how to solve expressions involvins commas

  4. #4
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    I dont think I really understand your question

    3 = (1,2) + (2,3) - (1,2) * (3,2) ?

    are you asking how to solve this problem in general or in c?
    -- Will you show me how to c++?

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    5
    the complete problem is like this
    Code:
    void main()
    {
    int a=1,b=2,c=3,d=4,e;
    e=(a,a)+(b,c)+(c,d)-(d,b);
    printf("%d",e);
    }
    and its answer is 6

    compiler is giving the output but i just want to know how it is being interpreted by compiler


    hope u understand my program now

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    That doesn't make a whole lot of sense to do, but out of the ordered pairs, only the second value will impact the result.

  7. #7
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by whiteflags View Post
    That doesn't make a whole lot of sense to do, but out of the ordered pairs, only the second value will impact the result.
    Yeah, the output give the same result as:

    e=a+c+d-b;

  8. #8
    Registered User
    Join Date
    Mar 2010
    Posts
    5
    Quote Originally Posted by whiteflags View Post
    That doesn't make a whole lot of sense to do, but out of the ordered pairs, only the second value will impact the result.
    thats why i asked this question it was given in a test of some software company, there were many others ques like this


    thanks for ur reply

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to solve this question?
    By zcrself in forum C Programming
    Replies: 9
    Last Post: 03-10-2010, 12:12 AM
  2. C++ Program to evaluate expressions
    By DMEngOba in forum C++ Programming
    Replies: 5
    Last Post: 05-25-2009, 09:16 PM
  3. Stack that evaluates postfix expressions
    By killmequick in forum C Programming
    Replies: 7
    Last Post: 10-01-2008, 06:23 PM
  4. Regular expressions [Boost]
    By Desolation in forum C++ Programming
    Replies: 8
    Last Post: 12-30-2006, 10:10 PM
  5. Replies: 2
    Last Post: 04-25-2005, 11:59 AM