|
-
May 21st, 2022, 02:12 AM
#4
Re: Palindrome Problem in C++
 Originally Posted by aartiyadav
The problem is that the program returns false even when the number is a palindrome.
Are you sure? I could not spot a bug, so I ran your code with jverd's test set in #3 and the results are identical. It suggests your code is working. Still, it will not work with negative integers. If you want that you need to make this change to the while loop,
Code:
while (tempOriginal != 0) {
And it will only work with integers up to 9-10 digits. That is the limit for a 32-bit integer. You can double this by using a 64-bit integer (a long long int).
Last edited by wolle; May 22nd, 2022 at 12:45 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|