Dark mode logo
Last Updated:
Finds if a word is palindrome or not in c

Read a string, Store it in an array and check whether it is palindrome word or not in C


Input: Input a string (Word)
output: Checks if it is a palindrome or not

  1. Start
  2. n = 0
  3. Read a string to check if its palindrome and store it in an array say str
  4. l = strlen(str)
  5. i = 0
  6. while ( i <l/2 )
    6.1 if str[i] != str[l-1-i]
      6.1.1 n = n+1
    6.2 i++
  7. if n == 0
    7.1 Print "It is a palindrome"
  8. else
    8.1 Print "It is not a palindrome"
  9. Stop

C Program

Note: gets() is a deprecated, so the following code may not work on your compiler.

#include <stdio.h>
#include <string.h>
int main()
int n = 0,l;
char str[30];
printf("Enter a word to check palindrome: ");
l = strlen(str); //Size of the inputed string.
// Checking for Palindrome
for(int i = 0; i <=l/2; i++ ) {
   if (str[i] != str[l-1-i]){
//Displaying if the entered word is palindrome or not
if (n==0) {
    printf("It is a palindrome.");
else {
   printf("It is not a palindrome.");
return 0;


Enter a word to check palindrome: Reviver
It is a palindrome.