Skip to content

Reverse Number Program - #161

Open
Santhoshi2010 wants to merge 3 commits into
Mathi27:mainfrom
Santhoshi2010:main
Open

Reverse Number Program#161
Santhoshi2010 wants to merge 3 commits into
Mathi27:mainfrom
Santhoshi2010:main

Conversation

@Santhoshi2010

Copy link
Copy Markdown

Reverse Number Logic Fix #7

Fixed the incorrect logic used to reverse a number with a while loop.
Removed the invalid use of reversed() on an integer and corrected the reverse algorithm.
Extracted each digit using num % 10 and built the reversed number with rev = rev * 10 + digit.
Updated the number using integer division (num //= 10) until it became 0.
The corrected implementation now produces the expected reversed number for valid integer inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in Reverse a Number

1 participant