Nov 18, 2013 at 8:03am UTC
Write a program that asks the user to prompt an Integer number and then test whether it is Palindrome Numbers or not.
The following are Palindrome numbers:
Nov 18, 2013 at 8:09am UTC
Hint: read it as a std::string and then keep comparing ith and (n-1-i)th characters.
Nov 18, 2013 at 8:17am UTC
Hi abhishekm71 Thank you But I am new in the site I am a beginner I didn't understand what you said ?? can you help me more??
Nov 18, 2013 at 10:10am UTC
You could edit your post to move it to the "Beginners" forum.
Courses usually provide info first and then give homework that depend on that info. The purpose of homework is to learn. You do learn best by doing.
Even though you may be a beginner, you must know something. Use that and do as much you can. Then show the result.
Nov 18, 2013 at 11:25am UTC
abhishekm 71 I know I don't want to give it to me but the problem that I don't understand it clearly and especially Palindrome
and keskiverto thank you I know that's why I signed up here...
Nov 18, 2013 at 12:12pm UTC
The loop looks two characters at a time, one from both ends of the word. If the are not the same, then the word is not a palindrome.
There is a way to hide the loop by using existing library code. First, make a copy of the word (std::string copy constructor). Then reverse that copy (std::reverse). Last, test the equality of the reversed copy and the original (std::string::operator==).
Start simple. Make a for-loop that prints out every character of the word, one at a time, and the index of that character.
Nov 18, 2013 at 1:34pm UTC
bool F(int number) //2013 - 11 - 02
std::string y = std::to_string(number);
std::string x = std::to_string(number);
for (int b = 0; b < x.length() / 2; b++)
std::swap(x[b], x[x.length() - b - 1]);
if (y == x)
change int to unsigned long long,if you want to check the palindromation of huge number
Nov 18, 2013 at 2:11pm UTC
I found it ... it as follows
using namespace std;
cout <<"Enter a number:";
cout<<"The number you entered is a Palindrome."<<endl;
cout<<"The number you entered is not a Palindrome."<<endl;
Thanks a lot