Saturday, November 22, 2008

C PROGRAM TO CHECK STRING PALINDROME

STRING PALINDROME

#include"string.h"
void main()
{
  char *str,*rev;
  int i,j;
  clrscr();
  printf("\nEnter a string:");
  scanf("%s",str);
  for(i=strlen(str)-1,j=0;i>=0;i--,j++)
            rev[j]=str[i];
            rev[j]='\0';
  if(strcmp(rev,str))
            printf("\nThe string is not a palindrome");
  else
            printf("\nThe string is a palindrome");
  getch();

No comments: