9 Jan 2015

PROGRAM TO FIND A GIVEN STRING IS PALENDROME OR NOT



#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{ clrscr();
  char s1[25],s2[25];
  int l,i,j=0;
  printf("Enter any string:\n");
  scanf("%s",s1);
  l=strlen(s1);
  for(i=l-1;i>=0;i--)
   {
    s2[j]=s1[i];
    j++;
   }
  s2[j]='\0';
  printf("The original string is :-%s\n",s1);
  printf("The reverse string is :-%s\n",s2);
  if(strcmp(s1,s2)==0)
   printf("The string is palendrome\n");
  else
   printf("The string is not palendrome\n");
  getch();
 }

No comments:

Post a Comment