15,957,998 members
1.00/5 (1 vote)
See more:
Write a C++ code that prompt a user to insert a number (just only one number) of four digits then print the number in reverse order.

Posted
Member 11186539 28-Oct-14 8:50am
e.g: if the number = 1234 then the output will be 4321.
joshrduncan2012 28-Oct-14 9:00am
What have you tried? Where are you stuck? How can we help you without seeing what you have tried?
King Fisher 28-Oct-14 9:11am
you must try Something
Member 10506391 28-Oct-14 9:28am
well first receive the input as a string but i think that's standard(could be wrong here)
a string is an array of chars, now think about what you can do with array's,
array[indexnumber] gets you a value.
now think about the position of a digit in that string array and think about what you could do with that
Richard MacCutchan 28-Oct-14 10:05am
Forget about C++ code for a minute and think about the problem. Write down on paper how you could solve this step by step. When you have figured that out, converting your steps into code will be a breeze.

## Solution 1

You should do your own homework.
That's really an easy task and there are several ways to code it. Surprise us with your creativity!
By the way: ask here only specific questions.

## Solution 2

Try With this:

C++
```int main ()
{
bool intEntered = false;
char input[255] ;
int number;

do{
cout<<"Input numbet: ";
cin >> input;
string s = input;
number = atoi(s.c_str());
if ( number == 0 )
cout << "Null is not alowed :) ";
else
intEntered = true;

}while(!intEntered);
}```

Then use for loop to read from last digit. Voila!!!!