convert int to string and then...

donde:
Well, the last statement didn't work.
It should be: int o = (n % 100) % 5; // 354 % 100 % 5 = 4

I should have stated, not for just 354, but for any number. So, I guess I should look into itoa()

That won't work either:

359 % 100 % 5 = 4

There was a small typo in PaulS' post. What you need is

int o = n % 10