Friday, September 21, 2012

program to check the string is palindrum or not

 check the string is palindrum or not.

#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
int i,j,l,c=0,n;
char a[20];
 printf("\nenter thestring\n");
 scanf("%s",a);
 n=strlen(a);
 j=n-1;
for(i=0;i<n/2;i++,j--)
{ if((a[i]!=a[j]))
  {
  c++;
  printf("\nnot palindrum\n");
  break;
  }
}
if(c==0)
{
 printf("\npalindrum\n");
}

getch();
}

No comments:

Post a Comment