tags:

views:

110

answers:

4

how to reverse the input number and get the output

A: 

Why dont you write a program. It should work as follows using modulus % and division / operator:

143 should give output as 341.

Praveen S
A: 

Google :

http://www.google.co.in/search?aq=1&oq=palidrome&sourceid=chrome&client=ubuntu&channel=cs&ie=UTF-8&q=palindrome+in+c

Please provide what you have tried already and what problems you are facing with it. Above google search should point you to programs available which you can refer.

YoK
A: 

If you are trying to reverse it as an integer think in terms of modulus (% operator). I would be more helpful, but it's homework so you should get the value of solving the problem.

dave
+2  A: 

Think of tasks like this by breaking them into the steps you'll need to do, and try writing down the steps. Then, see if you can code each step. Here's how I might start sketching:

  1. Get the number. ("12345")

  2. Reverse the number. ("12345 -> "54321")

  3. Print the result. ("54321")

But this isn't enough detail. We don't know how to code step 2 right away. So lets get some more detail:

  1. Get the number. ("12345")

  2. Split the number into a bunch of separate digits. ("12345" -> "1","2","3","4","5")

  3. Reorder the digits in reverse. ("1","2","3","4","5" -> "5", "4", "3", "2", "1")

  4. Combine the reversed digits to make a number ("5", "4", "3", "2", "1" -> "54321")

  5. Print the result. ("54321")

Try coding this. See if you get stuck on a particular step. If you do, try breaking it down again into smaller steps. If you have trouble breaking it down, you could google the step or ask on StackOverflow again. ("How do I split a number into separate digits?")

This is the basic way to solve most homework-style programming problems. Try it out, and come back if you have problems on any step, and ask about that step specifically.

Spencer Nelson