hey people please please please help me out with this. i have got my submission tommorrow and i have really worked hard on this i dont want it to turn out bad. this is a c program to convert infix expression to postfix without considering parentheses and already accepting that the given expression is a valid infix expression. what happens is the out is comin really weird. Code: #include<stdio.h> #include<conio.h> #include<string.h> int prece(char j); void main() { char infix[10],stack[5],output[10],j; int k=0,l=0,i,a,b; stack[k]=0; printf("write the infix expression to be converted to postfix"); scanf("%s",infix); for(i=0;i<10;i++) { a=prece(infix[i]); b=prece(stack[k]); if(a<=b) { output[l]=infix[i]; l++; } else { stack[k]=infix[i]; k++; } } for(i=k;i>0;i--) { output[l]=stack[i]; l++; } printf("%s",output); getch(); } int prece(char j) { if(j=='*'||j=='/') { j=3; } else { if(j=='+'||j=='-') { j=2; } else { j=1; } } return j; }
Re: c program to convert infix expression to postfix without considering parentheses Check InFix to PostFix and PostFix expression evaluation.
Re: c program to convert infix expression to postfix without considering parentheses hey thanks a lot !