Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

a simple algorithm to reverse the digits of a number

OpenStudy (anonymous):

in which language.

OpenStudy (rsmith6559):

The trick to this type of problem is to convert the number into a character string. A string is a collection of characters, so you can iterate over the collection and assemble (concatenate) a new string.

OpenStudy (e.mccormick):

And if the result needs to be a number, you can do the string back to a number after. Another way is to use % to get the remainders and strip off the last didgets one by one and add to a new number that you multiply by 10 as you go through each, and subtract off what you find so when the original is 0 you know you are done.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!