Thread: C++ Implementation of Special Case in Palindrome

  1. #1
    Registered User
    Join Date
    Apr 2020

    C++ Implementation of Special Case in Palindrome

    Hello All, I am new in C++ programming and trying to check the number is palindrome or not. Check the below code, The code have number 12321 is a palindrome number, but 1451 is not a palindrome number and what would happen if the number is greater than 1018?

    bool checkPalindrome(string original) {
      int n = original.size();
      for (int i = 0; i < n / 2; i++) {
        if (original[i] != original[n - 1 - i]) {
          return false;
      return true;
    Taking this code reference from <<spam removed>> Can anyone tell me, Is it right?
    Last edited by Salem; 05-19-2022 at 05:19 AM. Reason: spam removed - yet again!!!!

  2. #2
    Registered User
    Join Date
    Sep 2020
    The code you found looks very c-ish.
    It's much easier to check.

    bool is_palindrome(const std::string& s){
        std::string tmp(s.rbegin(), s.rend());
        return s == tmp;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with switch case messing up case variables
    By mp59 in forum C Programming
    Replies: 3
    Last Post: 07-02-2018, 12:12 PM
  2. Replies: 0
    Last Post: 03-09-2016, 03:58 PM
  3. * Operator in special case
    By HungryMan in forum C Programming
    Replies: 5
    Last Post: 05-08-2011, 01:00 AM
  4. Replies: 11
    Last Post: 08-25-2008, 12:01 PM
  5. upper case to lower case problem
    By Jasonymk in forum C++ Programming
    Replies: 3
    Last Post: 04-27-2003, 05:35 AM

Tags for this Thread