Why are you using the pos variable to determine whether the digit at that index is even or odd? That's just the index, not the digit itself.