Source Code: Abdullah Arshad FA19-BSE-104
Source Code: Abdullah Arshad FA19-BSE-104
Source Code: Abdullah Arshad FA19-BSE-104
FA19-BSE-104
SOURCE CODE
#include <iostream>
class ExpEvaluator
private:
char postFixExpression[ArySize];
public:
ExpEvaluator()
top = 0;
}
bool isExpressionValid(char Expression[])
Stack[top++] = Expression[i];
continue;
return false;
return false;
return false;
}
}
return true;
int j;
Stack[top++] = Expression[i];
continue;
if(
{
postFixExpression[j++] = Expression[i];
continue;
top = top-1;
postFixExpression[j++] = Stack[top--];
continue;
postFixExpression[j++] = Stack[top--];
top++;
Stack[top++] = Expression[i];
}
pfEcounter = j;
return true;
if(ch == '-')
return 1;
if(ch == '+')
return 2;
if(ch == '*')
return 3;
if(ch == '/')
return 4;
int postfixEvaluation()
else
num1 = numStack[--numStktop];
num2 = numStack[--numStktop];
if(postFixExpression[i] == '+')
if(postFixExpression[i] == '*')
if(postFixExpression[i] == '/')
return(numStack[--numStktop]);
}
int charToNum(char ch)
};
int main()
ExpEvaluator NE;
if(NE.isExpressionValid( Expression[]))
cout<<"Expression is valid";
if(NE.postfixConversion(Expression[]))
else
else
cout<<"Expression is valid";
}
}