How it works...

First, we will apply the mod 10 operator to separate our digits. Assuming the number entered by us is 153, you can see that 153 is divided by 10 and the remaining 3 is pushed to the stack:

Figure 3.4

The value in the stack is pushed at the index location indicated by top. Initially, the value of top is -1. It is so because before the push operation, the value of top is incremented by 1, and the array is zero-based, that is, the first element in the array is placed at the 0 index location. Consequently, the value of top has to be initialized to -1. As mentioned, the value of top is incremented by 1 before pushing, that is, the ...

Get Practical C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.