### Infix Expression:

- Operator is between operands
- Ex. a+b

### Postfix Expression (Reverse Polish Notation):

- Operator comes after operands
- Ex. ab+

### Prefix Expression (Polish Notation):

- Operator comes before operands
- Ex. +ab

What is the need to convert infix expression to postfix expression?

As we know, computer can not solve infix expression that we write usually while evaluating arithmetic expressions. Computer first convert infix expression that we have given as input into postfix expression and then using stack it will evaluate the expression.

One of the major application of stack is to convert infix expression to postfix expression and then evaluate the postfix expression.

### Infix to Postfix conversion using Stack Algorithm

Copy to Clipboard

### C Program for Infix to Postfix conversion using Stack

Copy to Clipboard

**Output:**

Thanks for Visit…….

C program to convert Infix expression to Postfix expression using Stack – KnowSharesFebruary 27, 2020 at 6:01 am[…] Infix Expression: […]

Add URLApril 19, 2020 at 5:39 pmI think you should make a video about this on YouTube…

Kaushik VaghaniApril 21, 2020 at 6:13 amI appreciated you comment. I will definitely look forward to create a video for this topic.

KunmingApril 26, 2020 at 5:46 amExcellent code! Can you remove additional parentheses in the input expression?

Kaushik VaghaniApril 27, 2020 at 4:18 amDear Kunming,

I appreciate you comment. In this program I have covered how to convert infix expression with parenthesis to postfix expression. So We need some condition to manage that parenthesis in stack for PUSH and POP. Now about additional parenthesis. In this particular code you can not remove additional parenthesis as that additional parenthesis at beginning and at end are for doing stack empty at end when whole infix expression has been processed and converted to postfix except only the operators that has been still in stack. So to empty the stack and append that remaining operators at end of postfix expression we need some condition like parenthesis in our case.

You can remove that parenthesis if you can change or alter some code for pop the stack at end when whole infix expression has processed. You can put something like “#” symbol at beginning and at end to tell compiler that now its end of expression and now you can pop the remaining operators from the stack and append that at end of postfix expression.

Hope you got my point.

Thank You.

PUSH and POP operations in Stack in C Program - TheKnowSharesMay 6, 2020 at 8:51 pm[…] Infix to Postfix conversion using Stack with C Program and Algorithm […]