+ 2
REVERSE ME
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.
4 Answers
+ 9
//using loops and recursion (2 methods ) âș
//hope it helps âș
https://code.sololearn.com/cX6szu5M3Lud/?ref=app
+ 5
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.
+ 2
thank you. :)
+ 2
Thank you. it helps so much@Gauruv