DSL PR 10
DSL PR 10
10
Title : Implement C++ program for expression conversion as infix to postfix and its evaluation
using stack based on given conditions:
3. Only '+', '-', '*' and '/ ' operators are expected.
Code :-
#include<iostream>
char stack[20];
int top=-1;
char postfix[20];
void expconver()
char infix[20];
int i=0;
int j=0;
cin>>infix;
for(i=0;infix[i]!='\0';i++)
top++;
stack[top]=infix[i];
}
postfix[j]=infix[i];
j++;
top++;
stack[top]=infix[i];
else
switch(infix[i])
case ')':while(stack[top]!='(')
postfix[j]=stack[top];
j++;
top--;
top--;
break;
case ']':while(stack[top]!='[')
postfix[j]=stack[top];
j++;
top--;
}
top--;
break;
case '}':while(stack[top]!='{')
postfix[j]=stack[top];
j++;
top--;
top--;
break;
postfix[j]='\0';
int main()
return 0;