write down the algorithm for reversing the digits of an integer
Answers
Answered by
6
Answer:
Where reverse is a variable representing the reverse of number.
Step 1 — Isolate the last digit in number. lastDigit = number % 10. ...
Step 2 — Append lastDigit to reverse. reverse = (reverse * 10) + lastDigit. ...
Step 3-Remove last digit from number. number = number / 10. ...
Iterate this process. while (number > 0)
Similar questions