You need to re-assign firstNum with ans at the end of your while loop. Implementation of 'c' can be done at the end by asking the user for a new firstNum and restarting your while-loop.