![]() |
|
#1
|
|||
|
|||
Reverse a number or digitsWrite program that reverse a number digits. The program will ask the user to enter a number (one variable) consist from three digits then the program reverse the digits of the number.
Note: you must define the number as integer. To solve the problem use the / and the % The program output might be like this Enter any number consist from three digits = 123 The reverse of this number= 321 |
|
#2
|
||||
|
||||
Re: reverse a number digitsYou will probably want to post the code you are using. You will be more likely to get help if you show your work first. Members are much more likely to jump in and help than to do your work for you.
Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#3
|
|||
|
|||
Re: reverse a number digitsCPP / C++ / C Code:
|
|
#4
|
|||
|
|||
Re: reverse a number digitsQuote:
Show something that you wrote. If it doesn't compile, then tell us exactly what the messages were. If it compiles but doesn't give the answers you expected, then tell us what you did get and what you didn't understand about it. Regards, Dave |
|
#5
|
||||
|
||||
Re: reverse a number digitsTaking the code you posted and commenting out all the lines with a question mark gives me...
CPP / C++ / C Code:
CPP / C++ / C Code:
It seems you got the least significant digit, Bravo! Now, you are going to want to use your short (int) and dividing by 10 to your advantage. Once you do that (and get the right answer) you just use the same method you used on a to find the new least significant digit. Rinse, Lather, Repeat Then just structure your output statement with the proper variables. At least that seems to be the assignment to me. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#6
|
|||
|
|||
Re: Reverse a number or digitswht they said is really good,
a standard logic to start working on it 4 u,.. CPP / C++ / C Code:
regrards surya Last edited by LuciWiz : 22-Jul-2007 at 09:33.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#7
|
|||
|
|||
Re: Reverse a number or digitsQuote:
Maybe something like: CPP / C++ / C Code:
Output: Code:
:davis: |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Converting a number amount to text | Godzilla | C++ Forum | 5 | 31-Mar-2006 11:38 |
| Repeated digits in a number sequence | pedro_21 | Java Forum | 1 | 01-Nov-2005 15:03 |
| Anyone can write a program code for this??? | chriskan76 | C Programming Language | 1 | 19-Oct-2004 20:25 |
| Breaking the number into two digits | amir_b | C Programming Language | 3 | 16-Feb-2004 12:28 |
| How to find the last 6 digits of a 8 digit number? | rjd72285 | C++ Forum | 3 | 28-Oct-2003 08:21 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The