A couple other things. Take a look at your while loop. while (cancel == cancel) . cancel is always going to equal cancel. This should probably be changed to while (true) , or while (cancel == 'c') , or something like that. The other thing is that a modulus operation would be no different to do than any of the other functions you have. Just number % number_2 .