C++ Program to Check whether a string is Palindrome or Not

  • How to Check whether a string is palindrome or not in C++.
  • C++ program for palindrome string check.

#include <iostream>

using namespace std;
int main(){
    char inputString[100];
    int l, r, length = 0;
    cout << "Enter a string for palindrome check\n";
    cin >> inputString;
    // Find length of string
    while(inputString[length] != '\0')
    // Initialize l(left) and r(right) to first and 
    // last character of input string 
    l = 0;
    r = length -1;
    // Compare left and right characters, If equal then 
    // continue otherwise not a palindrome
    while(l < r){
        if(inputString[l] != inputString[r]){
            cout<<"Not a Palindrome"<< endl;
            return 0;
    cout << "Palindrome\n" << endl;
    return 0;
Enter a string for palindrome check
Enter a string for palindrome check
Not a Palindrome

Recommended Posts
C++ Program to Convert Uppercase to Lowercase Characters
C++ Program to Count Words in Sentence
C++ Program to Delete a Word from Sentence
C++ Program to Print Array in Reverse Order
C++ Program to Delete Spaces from String or Sentence
C++ Program to Delete Vowels Characters from String
C++ Program to Find Power of Number using Recursion
C++ Program to Check Prime Number Using Function
C++ Program to Convert Decimal Number to Octal Number
C++ Program to Copy String Without Using strcpy
C++ Program to find length of string
All C++ Programs