C Program for Evaluation of Postfix Expression

C Program for Evaluation of Postfix ExpressionIn this program we evaluate the Postfix Expression, using the stack. For example, 456*+7- is the postfix expression, from left one by one it is inserted into the stack, and after evaluation the answer is 27. Read more about C Programming Language .
/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#define SIZE 50 /* Size of Stack */
#include <ctype.h>
int s[SIZE];
int top=-1; /* Global declarations */

push(int elem)
{ /* Function for PUSH operation */
s[++top]=elem;
}

int pop()
{ /* Function for POP operation */
return(s[top--]);
}

main()
{ /* Main Program */
char pofx[50],ch;
int i=0,op1,op2;
printf("nnRead the Postfix Expression ? ");
scanf("%s",pofx);
while( (ch=pofx[i++]) != '