> But if I use "mum", it doesn't match it with "mum".
your algorithm doesn't work with repeated characters.
take a look at the value of `chk' in that case, it doesn't make sense.
In case of "mum", the for the first letter 'm', chk will be incremented twice. You should not be doing that.
As ne555 said, you algorithm will not work for for the words having repeated char. Try printing chk before the the check.