How can we reverse a number by using Recursive ?

For example if a number is 123, the result will be 321.
is that any idea to help me? because i can't think about it... i poor on this chapter.

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by myk45

Paste the code, of whatever you have tried. We can help you build on that. Well, here is a hint:

Let the number be N

rev_num = rev_num * 10 + (N % 10)
N /= 10

You need to do this till N becomes 0.

Edited by myk45: n/a

may be you can use array and for? if you want solution of the problem http://letscoding.wordpress.com/ the reverser waiting for youbut you should try write own code,Before looking at the page

Paste the code, of whatever you have tried. We can help you build on that. Well, here is a hint:

Let the number be N

rev_num = rev_num * 10 + (N % 10)
N /= 10

You need to do this till N becomes 0.

sorry that i have never do the code,
because im still stucking what should i put for my if-statement and else-statement.
i have no idea what should i put on that so i came over here to ask for help.

Well, in my previous post, i pasted a hint. based on that, give it a try. Use a loop and try. Then you can go for an iterative approach.

You can learn best when you try it on your own.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.