How to convert Infix notation to postfix notation

Discussion in 'C Programming' started by Tameem, Oct 26, 2009.

  1. Tameem

    Seebs Guest

    Ayup. There's no meds for the autism that I know of. I wasn't medicated for
    ADHD back in the day either. I am (sort of) now.

    But I think Spinny misses the point. I was involved in C standardization
    because I was interested in it and was willing to spend the time to learn
    how the language worked so I could make informed comments. Schildt wasn't
    involved in standardization, and apparently lacked the motivation to spend
    the time to learn how the language worked. (Yes, TCR4E fixes a few of
    the bugs from previous editions... But leaves major flaws in place,
    getting things wrong in a way that suggests that the author never really
    did make it past Pascal.)

    Seebs, Nov 25, 2009
    1. Advertisements

  2. I think it was a bug; although context was incomplete, if used as
    seems to me reasonable, if the input data ended with a digit it would
    go into an infinite loop.

    But the change doesn't fix it. scanf() returns EOF, but doesn't set c
    to EOF; on plain char=unsigned it couldn't even if it tried.

    Aside: %1c is unnecessary (default) in %1c. getchar() and putchar(),
    would be more specific and I think clearer; fgetc() and fputc() with a
    FILE* variable would be more general.
    David Thompson, Nov 30, 2009
    1. Advertisements

  3. i want to covert infix in postfix expression usingg c# please any body helps me urgent
    bilawalali.uit, Sep 28, 2013
  4. Tameem

    James Kuyper Guest

    This group is for C; for expertise in C#, you'll need to look elsewhere.
    I couldn't find any newsgroups with "c#" in the newsgroup name,
    presumably "#" is not a permitted character. However, there's a wide
    variety of groups with "csharp" in their name. Choose one and post your
    question there.

    C does have postfix expressions, three of which are (almost) equivalent
    to infix expressions:

    *(a+b) => a
    a = a + 1 => ++a
    a = a - 1 => --a

    I say "almost" because the last two cases are not equivalent if 'a' is
    an expression with side-effects.

    However, it's not possible to convert arbitrary C infix expressions to
    postfix expressions. Possibly "infix" and "prefix" have a different
    significance in C#; but if that's not the case, when you post your
    message in an appropriate forum, you should explain in more detail
    precisely you mean.
    James Kuyper, Sep 28, 2013

  5. Since you were talking about postfix expressions, I presume you mean a++
    and a-- here. Also, a += 1 and a -= 1 are, I would say, a loser match.
    Neither form gets the value right (you need prefix ++ and -- for that)
    but they work when the expression 'a' has side-effects, and it uses only
    one infix operator.
    The language is not exact, but the OP almost certainly means "convert
    infix to postfix expressions using c#". You can do that using C too.
    It's a standard piece of coursework (though this may be self-study, of

    Ben Bacarisse, Sep 28, 2013
  6. When you post this question in a forum that actually deals with C#, it's
    likely they won't be willing to help you unless you show some actual
    effort. As written your question sounds like "Please do my homework for
    me". My usual response to such questions is to offer to submit the
    solution directly to your instructor, mentioning your name.
    Keith Thompson, Sep 28, 2013
  7. Tameem

    osmium Guest

    I suggest that you start with Wikipedia and then, perhaps, a more general
    look around on the web. Wikipedia is a great source for people studying
    computer science.
    osmium, Sep 28, 2013
  8. Tameem

    James Kuyper Guest

    No, I realized that a++ doesn't have an infix equivalent - (a=a+1) has
    the wrong value - so I changed it to ++a, forgetting that this made it
    no longer a postfix expression. Not exactly one of my better postings.

    It may be standard course work, and since you consider it such, you
    presumably know what it means - but I don't. Since the OP probably can't
    explain it, could you?
    I can think of any number of problems whose solution could be summarized
    by that description, but I can't figure out how to interpret it as a
    complete specification of what needs to be done.
    James Kuyper, Sep 29, 2013
  9. Tameem

    osmium Guest

    I didn't try to discover the last femto-thought in the question but I read
    it as "how do I convert ordinary algebraic notation to RPN?" whcih is a
    very common student assignment.

    And for the OP, RPN means Reverse Polish Notation.
    osmium, Sep 29, 2013
  10. Of course.

    Note that the "feigned ignorance" displayed by Jimmy, is a common CLC ploy.
    People pretend not to understand, when what they are really saying is:

    1) I don't like you. I.e., the feigned ignorance is a form of passive-aggression.

    2) There is a small chance that I don't know what you are talking about,
    and if I do guess wrong, then I might end up looking silly. Better to
    assume/feign ignorance than take a chance.

    Note that there is some validity to 2), but 1) is just classic CLC...
    Kenny McCormack, Sep 29, 2013
  11. What osmium said.

    Ben Bacarisse, Sep 29, 2013
  12. Tameem

    James Kuyper Guest

    Ahh! That makes sense. That actually was one of the problems I was
    thinking of that could be summarized that way - but I couldn't single it
    out as the most likely possibility. People who've had a lot of formal
    training in computer programming seem to share a lot of common
    experiences of this sort that I missed out on by being largely
    self-taught in the subject. I trained for a career in theoretical
    physics that turned out to require a better imagination than I possess.
    James Kuyper, Sep 29, 2013
  13. Tameem

    Eric Sosman Guest

    I, too, am principally self-taught, yet I encountered this
    transformation early on, in my very first internship. I couldn't
    understand what some of the code was doing, and found the comments
    to be of no help. This was in Olden Times, y'see, and the code
    was in ALL UPPER-CASE FORTRAN, and the comments looked like


    So I went to my supervisor and asked why the expressions needed
    polishing ...
    Eric Sosman, Sep 29, 2013
  14. Tameem

    osmium Guest

    Ah yes, one of those rare capitonyms. My least favorite one is calory.

    Actually, I was just looking for an excuse to mention that a sure tip-off
    for a student problem is the word "urgent", which the OP in this thread had.
    It means something like "I've had this damned thing since last Wednesday and
    I haven't even thought about it".
    osmium, Sep 29, 2013
  15. Tameem

    lakef66 Guest

    how are you
    lakef66, Jan 31, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.