C Program to Check if a Given String is Palindrome

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>
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;
      if (flag==1){
         printf(" string is not a palindrome");
      } else {
         printf("string is palindrome");
     return 0;
} Output : string is a palindrome

        Contact Us


  • LinkedIn
  • Facebook
  • Instagram

©2023 by Programmers Door