CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #4
    Join Date
    Feb 2017
    Posts
    674

    Re: Palindrome Problem in C++

    Quote Originally Posted by aartiyadav View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured