2026 - April - 05
why used reverse ?
A reverse loop is used process data end to the start, useful for like reversing number .
I will give flowchat
Coding
create 3 veriable
i.num -> store the give value
ii.rev -> store the reverse value
iii.digit-> store the last digit valuenext while loop condition num greater than 0 (0 > 0 ) condition fail loop stop
digit num % 10
gets the last digit,
why 10 ?
We use 10 because numbers are in the decimal
used in divides,multiple..rev*10 + digit value store in rev
Same time give decimal number can't run
Modify in without decimal usedMath.floor
num/10removes last digitRun repeat in loop fail
Print in Output 3210987
stop entire program
% 10 → last digit
reverse * 10 + digit → build reverse
/ 10 → remove last digit


Top comments (0)