You are getting remainder and the quotient in the same variable that causes your program to fail each time.
Look at your code carefully and you will come to know.