Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
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.

Help Me Please
Posted
Comments
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.

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.
 
Share this answer
 
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!!!!
 
Share this answer
 
Comments
Aescleal 29-Oct-14 6:38am    
There's enough rubbish C++ in the world - please don't add to it, even if you're being ironic.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900