how to write a program for this ?

write a program that prompts the user to input an integer number and then output the number with the digits reversed . For example if the input is 12345, the output should be 54321 . your program must also output 800 as 008 and 130 as 031 and -123 as -321 .Your program sholud continue ask the user for input until the response is negative . your program must include an function called reverseDigit that accept the input number as parameter and return to the calling function number with the digits reversed
By breaking it down to steps and then completeing each step. Here are some steps. When you have written code for them all, if it doesn't work, come back with he bad code and we'll help more.

1) Prompt user for input with words on screen.
2) Fetch input from user as a string
3) Call function reverseDigit that does the following steps:
i) Break string into individual letters
ii) Check each letter represents a digit
iii) Use a string function to reverse the string (preserve leading negative symbol if it exists)
iv) Return reversed string
4) Output returned string to screen.

As you may have realised, code syntax is the easy bit. The difficult bit is actually thinking about how to solve problems. Note that in this task, there's no need to ever actually deal with the input as a number. Only as a string, and checking that each letter does represent a digit.
Last edited on
Please stop posting homework questions without even trying to solve them yourself. Try to actually do them, it is, after all, your homework. You'll never pass if you don't even try.

http://cplusplus.com/forum/general/38008/
http://cplusplus.com/forum/general/38009/
http://cplusplus.com/forum/general/38012/ (this)
no its not mine . im not even studying c++ . my friend is a poor student , and he's my best friend . so i have the internet connection to help him find the solution for c++
Well then take the steps above to him, and he can do them. To be honest, I've probably gone a bit too far with them, but there's no code provided so he'll still have to do that all himself.
this is urgent . he needs it asap . anyone could help with it ? please reply asap
You haven't posted any code whatsoever in this thread, if your friend is a student who doesn't even know where to start with this problem, then he didn't pay attention in class and deserves to fail. To get good at programming requires a lot of work, there is no way around it.
roger that . i'll show this to him asap
Topic archived. No new replies allowed.