โ Back to Loops
Question 301
Reverse a Number (while)
Reverse a Number (while)
The variablenholds1234. Use awhileloop to build its reverse (4321) and print: Reversed: 4321 Build the result withrev = rev * 10 + n % 10;while peeling digits offn.
Expected Output:
Reversed: 4321
Topics:
Loops
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.