Evaluating A Postfix Expression Using Stack DataStructures
#include"stdafx.h" #include<math.h> #include<iostream> # define MAX_STACK 150 using namespace std; class stacks { int value,item,top; int stack[MAX_STACK]; public: stacks() { top=(-1); } void push(float); float pop(); }; void stacks::push(float value) { if(top==MAX_STACK) { cout<<"Stack is full!\nOverflow!"; exit(0); } else top++; stack[top]=value; } float stacks::pop() { if(top<0) { cout<<"Stack is empty!\nUnderflow!"; exit(0); } else item=stack[top]; top--; return(item); } int main() { stacks stk1; char expression[150],oper_string[8],ch; oper_string[0]='\0'; float value,operand1,operand2,val; int pos=0,p=0; cout<<"Enter a postfix expression: "; gets(expression); while(expression[pos]!='\0') { ch=exp