Question: Using a stack calculator code, implement the following functions. The calculator code should be able to store more than 2 operands and use a stack
Using a stack calculator code, implement the following functions. The calculator code should be able to store more than 2 operands and use a stack to hold up to MAX_STACK_SIZE operands.
void clearCalculator(): code runs when a user inputs the c or clear calculator command. Returns a void. By specifying void, assume any possible error the routine encounters is hidden from the caller.
unsigned int doOp(unsigned int N1, unsigned int N2, char Op): This code performs the mathematical operation specified by a provided operator (Op) parameter using the two numbers when supplied. For example, a subtraction operation is defined as: N1 N2. The result from the operation is returned. To simplify, assume the function hides any errors from the caller. If an error, the routine should return a 0
char getNextCharacter(int characterSetID): returns next valid character from the standard input stream. Should be used in instead of scanf(). If no data available, the function should block until data becomes available. Similar to the C librarys getchar() routine. Implementation should support the characterSetIDs listed below.
1. Returns a character from standard input that is in the character set defined by the characterSetID parameter. A CHAR_ERROR is returned if an error occurs.
2. int characterSetID : identifies a subset of ascii character codes that the caller prefers. Use macro or enumerated data type to represent these choices:
An alphanumeric - number (0 9), any lower case or upper case letter (a-z, A- Z).
Calculator Command Set 1 - this includes q, c, d, h
Calculator Command Set 2 - this includes q, c, d, h, +, -, *, /
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
