float POSTFIX_EVALUATION(char* postfix_arr, int lengthofpostfix) { STACK<float> STACK; //Initializes evaluation float stack float answer = 0, temp = 0, operandx = 0, operandy = 0; //Final evaluated answer variable int i = 0, c = 0; //Counters and operand variables char op, check; //Operator variable for (c = 0; c < lengthofpostfix; c++) //For postfix equation { (char)postfix_arr[i]; if (postfix_arr[i] >= 'a' && postfix_arr[i] <= 'z'){ //If operand STACK.PUSH2((float)postfix_arr[i]); //PUSHes operand to stack i++; //Increments postfix array } else if(postfix_arr[i] == '+' || postfix_arr[i] == '-' || postfix_arr[i] == '/' || postfix_arr[i] == '*'|| postfix_arr[i] == '^'){ //If Operator op = postfix_arr[i]; //Sets operator to postfix array slot operandx = STACK.POP2(); //Retrieves operand 1 from stack operandy = STACK.POP2(); //Retrieves operand 2 from stack answer = solve(op,operandy,operandx); //Solves the postfix STACK.PUSH2(answer); //Pushes the answer onto the stack i++; //Moves to next value in postfix array } } answer = STACK.Return_Top_of_Stack2(); //Returns final answer from stack STACK.POP2(); return answer; }