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

flowchart to reverse digits of an integer

OpenStudy (anonymous):

Cast to string -> reverse string (most libraries have good string functions) , cast back to int.

OpenStudy (anonymous):

If its a decimal number you could use modulus function to return the first lowest digit in the integer like 45%10 would give you a 5. Doing that recursively would give you the number reversed. Flow: (example 123) num = 123 loop print num%10 (prints 3) num = num/10 (num now is 12 - integer division removes remainder) end loop result : 321

OpenStudy (anonymous):

do it recursively: method(number) { if(number > 1) ///Base Case { digit = pull off the last digit newNum = the number without the first digit return digit + method(newNum } return number; }

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!