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

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 space, next state is 4
If is end of string, next state is 5
If anything else, next state is 6
1. Found operator:
Pop 2nd number off stack
Pop 1st number off stack
Perform operation
Push result on stack
Next state is 0
Note: Watch popping empty stack and division by zero
2. 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 2
otherwise
next state 3
3. Found end of number:
append \0 on temporary array
convert and assign to variable
push number on stack
reset temp index to 0
decrease input index by 1
next state is 0
4. Found space:
next state is 0
5. Found end of input string:
pop result
return answer
Note: Watch for leftovers on stack
6. 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!