GoogelAddUnit1

Monday 16 April 2012

WRITE A C-PROGRAM TO TEST THE GIVEN STRING IS PALLIDROM (OR) NOT.

AIM:A program to test the given string is pallindrom (or) not.


PROGRAM:
#include<stdio.h>
main()
{
char a[30],c;
int i,j,l,f=0;
printf("enter any string");
scanf("%s",a);
for(l=0;a[l]!='\o';l++)
printf("%d",l);
for(i=0,j=l-1;i<l/2;i++,j--)
{
if(a[i]==a[j])
f=1;
}
if(f==1)
printf("it is a pallindrom");
else
printf("it is not a pallindrom");
}

OUTPUT:
enter any string
madam
it is a pallindrom
enter any string
sudha
it is not a pallindrom

No comments:

Post a Comment