id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2021_04_29_APP1SLHL_reverseNum
prev  |  next  |  chance

Write a method that returns an integer that is made up of the digits in 'num', but in reverse order. You may NOT use any strings, arrays, array lists, maps, or any other advanced data structures. In fact, you may ONLY use integer variables! You can do this recursively or iteratively. I can do it recursively in one line or iteratively in 5 lines (not counting the header or braces). Think div and mod! Note: When you reverse 900 you get 009, but that just gets returned as a 9.


test2021_04_29_APP1SLHL_reverseNum(5000) → 5
test2021_04_29_APP1SLHL_reverseNum(4070) → 704
test2021_04_29_APP1SLHL_reverseNum(8) → 8

...Save, Compile, Run (ctrl-enter)

public int test2021_04_29_APP1SLHL_reverseNum(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 250

Copyright Nick Parlante 2017 - privacy