The Algorithm For Is Given: Evaluating A Postfix Expression CC
The Algorithm For Is Given: Evaluating A Postfix Expression CC
op1=op2; op2=n; } if(ch=='+') n=op1+op2; else if(ch=='-') n=op1-op2; else if(ch=='*') n=op1*op2; else if(ch=='/') n=op1/op2; else if(ch=='%') n=op1%op2; else { printf("The operator is not identified\n"); exit(0); } printf("n=%d\n",n); return(n); } int main() { char str[50],ch,ch1; int i=0,n,op1,op2; printf("Enter the Postfix string\n"); scanf("%s",str); ch=str[i]; while(ch!='\0') { printf("The char is=%c\n",ch); //if(ch=='1' || ch=='2' || ch=='3' || ch=='4' || ch=='5')// if(isdigit(ch)) { n=ch-'0'; push(n); } else { op1=pop(); op2=pop(); n=evaluate(op1,op2,ch); push(n); } ch=str[++i]; } printf("The value of the arithmetic expression is=%d\n",pop()); return; }
You might also like: y Airline Reservation System in C y C Programs Based on Queue
Links to this post Posted by Sunitha at 15:38 0 comments Email ThisBlogThis!Share to TwitterShare to Facebook Labels: Algorithm Implementation, C Simple Projects, Data Structure Programs Reactions: