Program to convert expression in postfix form to prefix form
#include #include #include #define MAX 50 struct postfix { char stack[MAX][MAX], target[MAX] ; char temp1[2], temp2[2] ; char str1[MAX], str2[MAX], str3[MAX] ; int i, top ; } ; void initpostfix ( struct postfix * ) ; void setexpr ( struct postfix *, char * ) ; void push ( struct postfix *, char * ) ; void pop ( struct postfix *, char * ) ; void convert ( struct postfix * ) ; void show ( struct postfix ) ; void main( ) { struct postfix q ; char expr[MAX] ; clrscr( ) ; initpostfix ( &q ) ; printf ( "\nEnter an expression in postfix form: " ) ; gets ( expr ) ; setexpr ( &q, expr ) ; convert ( &q ) ; printf ( "\nThe Prefix expression is: " ) ; show ( q ) ; getch( ) ; } /* initializes the elements of the structure */ void initpostfix ( struct postfix *p ) { p -> i = 0 ; p -> top = -1 ; strcpy ( p -> target, "" ) ; } /* copies given expr. to target string */ void setexpr ( struct postfix *p, char *c ) { strcpy ( p -> ta...