C program to check String is Palindrome

/* Before moving towards the program, a little introduction to the one who dose not know what is palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction i.e if we look from the backwards or from the front , they look same. Here are some examples that will help you to understand it better. Ex:  12321 , 676, nitin, madam, arora etc. No we move ahead to program to check whether a String is Palindrome or not palindrome */.

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

  char st[20];

  int flag=0,i,l;

  clrscr();

  printf(“enter any string\n”);

  gets(st);

  l=strlen(st);

  for(i=0;i<l/2;i++)

     if(st[i]!=st[l-1-i])

     {

      flag=1;

      break;

     }

  if(flag==0)

    printf(“String is Palindrome “);

  else

    printf(“String is not palindrome \n”);

getch();

}

Mohit Arora
Follow me