How it works...
Let's assume that the number we entered is 737. Now, we want to know whether 737 is a palindrome. We will start by applying the mod 10 operator on 737. On application, we will receive the remainder, 7, and the quotient, 73. The remainder, 7, will be pushed to the stack. Before pushing to the stack, however, the value of the top pointer is incremented by 1. The value of top is -1 initially; it is incremented to 0 and the remainder of 7 is pushed to stack[0] (see Figure 3.21 ).
The mod 10 operator returns the last digit of the number as the remainder. The quotient that we get on the application of the mod 10 operator is the original number with its last digit removed. That is, the quotient that we will get on the application ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access