Question: 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

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
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
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
Found end of number:
append 10 on temporary array
convert and assign to variable
o push number on stack
reset temp index to 0
decrease input index by 1
next state is 0
Found space:
next state is 0
Found end of input string:
pop result
return answer
Note: Watch for leftovers on stack
Found garbage
display error message
exit from program
Write in C programming
Starting State: Increment input string's index

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!