Skip to content

Commit d65d4fa

Browse files
committed
feat: Implement logic to reverse a given number using modulus and division
🧠 Logic: - Extract digits from the number using `% 10`. - Build the reversed number by multiplying `rev` by 10 and adding the digit. - Repeat until the original number becomes 0. - Print the reversed number at the end. Signed-off-by: Somesh diwan <[email protected]>
1 parent 717d539 commit d65d4fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Section8LoopAB/src/ReverseANumber.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public static void main(String[] args) {
1515
rev=rev*10+r;
1616
n/=10;
1717
}
18-
System.out.println("Revserse Number is: "+rev);
18+
System.out.println("Reverse Number is: "+rev);
1919
}
20-
}
20+
}

0 commit comments

Comments
 (0)