Start by thinking about it: what is a decimal digit? How do I remove one? How do I add one?
Well, to the 3rd digit of this number: 654321 is "4", and I'd remove it by converting the 3 to a power of ten: 1000.
If I divide the base number by 1000 * 10 I get 65. If I multiply that by 1000 * 10 I get 650000.
If I take the remainder of the original number and 1000, I get 321.
So adding those two together has removed the third digit:
removed = (x / 10000) * 10000 + (x % 1000)
Similarly, I can extract the digit very easily:
digit = (x / 1000) % 10
And just by changing the power-of-ten value I can do the same for the first digit:
removed = (x / 10) * 10 + (x % 1)
digit = (x / 1) % 10
So... if you write a two functions to remove a digit and return a digit given
x
and the digit power-of-ten all you have to do is call each of them twice and then multiply and add.
Does that make sense?