In this program, we will learn how to check the given string is palindrome or not.
For Example- A string is said to be palindrome if the reverse of the string is the same as string.
For example,
Input − namanÂ
Output − string is a palindromeÂ
Input − ProgrammerDoor
Output − string is not a palindrome
Â
Implementation:
#include <iostream>
#include<string.h>
using namespace std; {
  int main(){
   char string1[]={"naman"};
   int i, length;
   int flag = 0;
   length = strlen(string1);
   for(i=0;i < length ;i++){
     if(string1[i] != string1[length-i-1]) {
      flag = 1;
      break;
     }
   }
   if (flag==1){
     printf(" string is not a palindrome");
   } else {
     printf("string is palindrome");
   }
   return 0;
  }
}
Output :
string is a palindrome