I'm working to make a program which will subtract a pair of numbers until it reaches kaprekars constant.
in cases where the number is <1000, we are supposed to take the number and add a leading zero to it.
i.e 999 would become 0999.
I have a feeling this has something to do with the format specifiers, but I'm under the assumption that the leading zeros are not actually part of the number.
Am I totally barking up the wrong tree or am I close to what I need?
Here is my code for reference
Code:
remainders = userInput % 1000;inputVariables[0] = userInput / 1000;
userInput = remainders;
remainders = userInput % 100;
inputVariables[1] = userInput / 100;
userInput = remainders;
remainders =userInput % 10;
inputVariables[2] = userInput / 10;
userInput = remainders;
inputVariables[3] = remainders;
numberY = (inputVariables[0]*(1))+(inputVariables[1]*(10))+(inputVariables[2]*(100))+(inputVariables[3]*(1000));
return numberY;