C Programming Code Examples C > Strings Code Examples C program to check whether a string is palindrome or not C program to check whether a string is palindrome or not Write a C program to check whether a string is palindrome or not without using loop. How to check whether a string is palindromic string or not in C programming. What is Palindromic string? Palindrome string is a special string which reads same from backward or forward such as madam, mom, eye, dad etc. The basic idea behind checking palindrome is if it can be read same from forward and backward then it is palindrome else not. Here in the below algorithm we will traverse the string character by character in both direction at the same time if they are equal then the string is palindrome. Below is the step by step descriptive logic to check palindrome string. Input a string from user, store it in some variable say str. Find length of the given string and store it in some variable say endIndex. Initialize another variable, to traverse the string in forward direction say startIndex = 0. Run a loop until either startIndex >= endIndex or str[startIndex] != str[endIndex]. Otherwise increment startIndex and decrement endIndex. Finally after loop check if startIndex >= endIndex then string is palindrome. #include <stdio.h> #define maxsize 100 // Maximum string size int main() { char str[maxsize]; int len, startIndex, endIndex; /* Input string from user */ printf("Enter any string: "); gets(str); /* Find length of the string */ len = 0; while(str[len] != '\0') len++; startIndex = 0; endIndex = len-1; while(startIndex <= endIndex) { if(str[startIndex] != str[endIndex]) break; startIndex++; endIndex--; } if(startIndex >= endIndex) { printf("String is Palindrome."); } else { printf("String is Not Palindrome."); } return 0; }