Creates an array to be used as stack for storing values.
int stackTop
Represents the index of the last value added to array. -1 means array is empty.
std::array< float, 20 > stack
Array which will be used to store numbers in the input.
Functions for Postfix Expression algorithm.
float pop(Stack *stack)
Popping operand, also called the number from the stack.
bool is_number(const std::string &s)
Checks if scanned string is a number.
void evaluate(float a, float b, const std::string &operation, Stack *stack)
Evaluate answer using given last two operands from and operation.
static void test_function_2()
Test function 2 with input array {'1', '2', '+', '2', '/', '5', '*', '7', '+'}.
static void test_function_1()
Test function 1 with input array {'2', '3', '1', '*', '+', '9', '-'}.
void push(float operand, Stack *stack)
Pushing operand, also called the number in the array to the stack.
float postfix_evaluation(std::array< std::string, N > input)
Postfix Evaluation algorithm to compute the value from given input array.