Algoritham to reverse a number
Answers
Answered by
0
Explanation:
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)
Repeat this process until number is reduced to zero and reverse is completed.
Answered by
0
Algorithm:
> get the number as input which you want to reverse.
> Initialize the reverse_number to 0.
> Loop while number is greater than 0.
-multiply reverse_number by 10 and add remainder of number.
- divide by 10 to reverse_number
:: reverse_number = reverse_number*10 + number%10
- divide number by 10.
> Return the reverse_number.
hope you understood..
Similar questions