[Solved] Understanding int reversing logic [closed]


Its talking the last char of your input by using modulo.

input is: 12345

Cycle 1:

  1. new_num is 0, multiply by 10 give 0.
  2. add modulo or your input 12345 % 10 = 5, new_num is now 5.
  3. divide your input by 10 to remove last digit. input = 1234

Cycle 2,3,4 etc.:

  1. new_num is 5, multiply by 10 gives 50.
  2. add modulo or your input 1234 % 10 = 4, new_num is now 54.
  3. divide your input by 10 to remove last digit. input = 123

solved Understanding int reversing logic [closed]