I wanna ask,
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.

Recommended Answers

All 4 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.