C Program to Check String is a Palindrome or Not

Using this tutorial, We are going to execute the script of “C Program to Check String is a Palindrome or Not”. Below, We can see the possibilities to perform the task using this tutorial.

C Program to Check String is a Palindrome or Not

C Program to Check String is a Palindrome or Not

Source Code

#include<stdio.h>
#include<string.h>

void main()
{
 /*Visit - www.programmingwithbasics.com*/
   
    printf("=====================================");
    printf("nVisit - www.programmingwithbasics.com");
    printf("n=====================================");

 while(1)
 {
    char string1[20];
    int i, length;
    int flag = 0;
    printf("nnEnter a String: ");
    scanf("%s", string1);
    length = strlen(string1);
    for(i=0;i < length ;i++)
  {
        if(string1[i] != string1[length-i-1])
    {
            flag = 1;
            break;
     }
  }
    if (flag)
  {
        printf("nn%s Is Not a Palindromen", string1);
    }  
    else 
 {
        printf("nn%s Is Palindromen", string1);
    }
 }
    return 0;
}

Conclusion

I hope this article helps you to learn “C Program to Check String is a Palindrome or Not”. If you face any issues please let me know via the comment section. Share this article with other C/C++ developers via social networks.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment