How to convert Infix notation to postfix notation

S

Seebs

I didn't know there *was* a mediacation for autism. Are you confusing
it with Attention Deficit Disorder?

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.)

-s
 
D

David Thompson

[...] "Algoritmi in C" by Robert Sedgewick
modulo bugs; [don't know if this is a bug
 while(c>='0' && c<='9')
     {printf("%1c", c); scanf("%1c", &c);}
should be
while(c>='0' && c<='9')
     {printf("%1c", c); scanf("%1c", &c);
      if(c==EOF)  goto endL;
     }
]

I don't think that was a bug. Note I'm looking at the Pascal version
of the algorithm so there may be some differences (I doubt it though)
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.
 
B

bilawalali.uit

i want to covert infix in postfix expression usingg c# please any body helps me urgent
 
J

James Kuyper

i want to covert infix in postfix expression usingg c# please any body helps me urgent

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.
 
B

Ben Bacarisse

James Kuyper said:
i want to covert infix in postfix expression usingg c# please any body helps me urgent

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


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.
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.

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
course).

<snip>
 
K

Keith Thompson

i want to covert infix in postfix expression usingg c# please any body
helps me urgent

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.
 
O

osmium

i want to covert infix in postfix expression usingg c# please any body
helps me urgent

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.
 
J

James Kuyper

James Kuyper said:
i want to covert infix in postfix expression usingg c# please any body helps me urgent

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


Since you were talking about postfix expressions, I presume you mean a++
and a-- here.


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.
Sorry!

....
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
course).

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.
 
O

osmium

James Kuyper said:
James Kuyper said:
On 09/28/2013 11:28 AM, (e-mail address removed) wrote:
i want to covert infix in postfix expression usingg c# please any body
helps me urgent

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


Since you were talking about postfix expressions, I presume you mean a++
and a-- here.


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.
Sorry!

...
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
course).

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.


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.
 
K

Kenny McCormack

osmium said:
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.

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...
 
B

Ben Bacarisse

James Kuyper said:
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?

What osmium said.

<snip>
 
J

James Kuyper

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.

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.
 
E

Eric Sosman

[...]
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.

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, 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

C BUILD POLISH EXPRESSION

So I went to my supervisor and asked why the expressions needed
polishing ...
 
O

osmium

Eric Sosman said:
[...]
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.

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, 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

C BUILD POLISH EXPRESSION

So I went to my supervisor and asked why the expressions needed
polishing ...

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".
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,075
Messages
2,570,545
Members
47,197
Latest member
NDTShavonn

Latest Threads

Top