Click here to Skip to main content
11,922,587 members (29,963 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked

Create Postfix from infix experssion.

, 19 Aug 2006
Rate this:
Please Sign up or sign in to vote.
this article create postfix experssion from an infix experssion.
<!-- Article Starts - DO NOT ADD HTML/BODY START TAGS-->


Ali reza zareian.

This is a simple program that creates postfix expression from an infix expression. What is an infix expression?


 (a+b)/d is a simple one. The infix expression is regular for mathematic. it means when u want to calculate this u must

Add a with b at the first time then divided with d.

If  we change this expression to postfix. We have this one ab+d/.

What is the useful of postfix?

 At first we don't need parantes.Second we can write a program to calculate this expression easier than infix expression.


What is this program?

 This programe use a simple algoritm to change infix to postfix.Just sees the example

Before I should say I use stack in this program.


Infix Program =(a+b)/d 



Input     Stack        output

(             (

a            (                     a

+           (+                   a

b           (+                   ab

)                                  ab+

/            /                     ab+

d                                 ab+d

No         empty           ab+d/



Main method of this program!?

1)      private int isOperand(char  chrTemp);

2)      private int isOperator(char chrTemp);

3)      public string createPrifex();



1) isOperand check character if they are in this set.{'*','/','+','-','^','('}

      If true we add this character to stack.


2)isOperator check character if they are in this set.{'*','/','+','-','^'}

    This  method check the  stack  and  pop all the operator except '('.


3)createPrifix method create postfix from infix use isOperand and isOperator.




 For (the first infix character ) to  last character


   If  (is operand)   add to stack


   If  (it is ')' )   pop  stack and send it to output

Else send other character to output












This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Software Developer
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
Where is the truth?

You may also be interested in...

Comments and Discussions

GeneralM_k Pin
m _k16-Oct-13 8:01
memberm _k16-Oct-13 8:01 
GeneralMy vote of 1 Pin
Mohamad K Ayash3-Oct-09 12:30
memberMohamad K Ayash3-Oct-09 12:30 
GeneralIncorrect Solution Pin
naeem_libra8-Dec-08 20:50
membernaeem_libra8-Dec-08 20:50 
GeneralRe: Incorrect Solution Pin
ali_reza_zareian21-Jan-09 8:24
memberali_reza_zareian21-Jan-09 8:24 
GeneralBetter method Pin
PIEBALDconsult11-Jun-08 18:26
memberPIEBALDconsult11-Jun-08 18:26 
GeneralWATCH OUT! This solution is wrong!! Pin
Member 451662817-Mar-08 14:14
memberMember 451662817-Mar-08 14:14 
GeneralRe: WATCH OUT! This solution is wrong!! Pin
ali_reza_zareian18-Mar-08 10:14
memberali_reza_zareian18-Mar-08 10:14 
GeneralRe: WATCH OUT! This solution is wrong!! Pin
PKokkula27-Jul-09 3:16
memberPKokkula27-Jul-09 3:16 
Generalplz help me Pin
behruoz guozali asl8-Dec-07 8:01
sussbehruoz guozali asl8-Dec-07 8:01 
AnswerRe: plz help me Pin
ali_reza_zareian21-Jan-09 8:07
memberali_reza_zareian21-Jan-09 8:07 
Generalprecedence logic is missing Pin
SoftwareCat17-May-07 6:11
memberSoftwareCat17-May-07 6:11 
QuestionGood? Pin
azam's25-Feb-07 20:03
memberazam's25-Feb-07 20:03 
GeneralDon't meant to complain but... Pin
Herbert Sauro21-Aug-06 20:41
memberHerbert Sauro21-Aug-06 20:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151125.1 | Last Updated 20 Aug 2006
Article Copyright 2006 by ali_reza_zareian
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid