Question: 0 . Starting State: Increment input string's index value If is operator, next state is 1 If is digit, next state is 2 If is
Starting State:
Increment input string's index value
If is operator, next state is
If is digit, next state is
If is space, next state is
If is end of string, next state is
If anything else, next state is
Found operator:
Pop nd number off stack
Pop st number off stack
Perform operation
Push result on stack
Next state is
Note: Watch popping empty stack and division by zero
Found digit:
Copy digit to temporary string
increment both the temporary and input string index values
If character in input string is a digit or decimal point
next state is
otherwise
next state
Found end of number:
append on temporary array
convert and assign to variable
push number on stack
reset temp index to
decrease input index by
next state is
Found space:
next state is
Found end of input string:
pop result
return answer
Note: Watch for leftovers on stack
Found garbage
display error message
exit from program
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
