Please post your code in [code][/code] tags, tell us exactly what is not working, what input you give it, and the output you get or the exact compiler errors you get.
BTW, I edited my post above and gave one reason why your while loop might not work. See if that is the issue.