Signup/Sign In

C++ Program to check String is Palindrome or not

In this tutorial, we will how to check string is palindrome or not.

Check String is Palindrome or not In C++ Language

Before moving to the programming let's have a look on what exactly is the statement with the help of a example.

Input: S = “ABCDCBA”
Output: Yes
The reverse of the given string is equal to the (ABCDCBA) which is equal to the given string. Therefore, the given string is palindrome.

// C++ program for the above approach
#include <bits/stdc++.h>
using namespace std;

// Function to check whether string
// is palindrome
string isPalindrome(string S)
	// Iterate over the range [0, N/2]
	for (int i = 0; i < S.length() / 2; i++) {

		// If S[i] is not equal to
		// the S[N-i-1]
		if (S[i] != S[S.length() - i - 1]) {
			// Return No
			return "No";
	// Return "Yes"
	return "Yes";

// Driver Code
int main()
	string S = "ABCDCBA";
	cout << isPalindrome(S);

	return 0;



Here, in this tutorial, we have learned how to determine whether a given string is palindrome or not.