REVERSE ME | Sololearn: Learn to code for FREE!



LIMITATIONS: NO ARRAY, NO BUILT IN FUNCTION. An integer that has a min. number of 4 digits and max of 10 digits. Sample input: 1234567 Sample output: 7654321 please help me with this one ASAP.

10/16/2016 1:45:44 PM

Johannes Remotigue

5 Answers

New Answer


//using loops and recursion (2 methods ) ☺ //hope it helps ☺


I'll give you a rough sketch. Seperating the last digit from the others is as easy as dividing by 10: int a = 1234; int division = a / 10; // 123 int remainder = a % 10; // 4 You'll also need a total which will store the result. It starts out as 0, and during each iteration you do: total = total * 10 + remainder; And that's it. You do that in a loop until you've consumed all the digits. Try printing out the division, remainder, and total at each step so you get a feel for what's going on.


thank you. :)


Thank you. it helps so [email protected]


Oh my god. you use ASAP And you two are using such a movie frozen word?!