CJCoding With Joseph

Reverse a Number (while)

The variable n holds 1234. Use a while loop to build its reverse (4321) and print:

Reversed: 4321

Build the result with rev = rev * 10 + n % 10; while peeling digits off n.

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.