Reverse digit by using loops

Jul 6, 2010 at 4:32am
This is the question.
Write a program that prompts the user to input a positive integer number and then output the number with the digit reversed.For example if the input is 45678, the output should be 87654.Your program must also ouput 8000 as 0008 and 230 as 032.
I dint have any idea for this question.Can anyone to help me and give me some idea about this question.Thanks.
Jul 6, 2010 at 7:50am
Show us what you've done so far and where you are having troubles.
Jul 7, 2010 at 11:01am
here's a hint, u can use strlen function to returns the length of string, and do looping from behind
example :

123456 -> length : 6
scan array, arr[0]=1,arr[1]=2,arr[2]=3,arr[3]=4,arr[4]=5,arr[5]=6
loop from (length-1) to 0 and print it
Jul 7, 2010 at 11:09am
Thanks for your helping...i solve this problem already.but can you show me how to do repetition by using while loops?Thanks.
Jul 7, 2010 at 1:18pm
Post your working solution, then we can help you convert it to a while loop.
Jul 7, 2010 at 2:26pm
A simple modulus (remainder) and divide function will do what you want.
To use a while loop read your textbook.
Jul 8, 2010 at 11:42am
Thanks for all your comment...I already solve it...Thanks a lot...
Last edited on Jul 8, 2010 at 11:42am
Topic archived. No new replies allowed.