Strings which are read the same, both forward and backward are called Palindrome Strings eg:malayalam. Palindrome checking is a Common Program for Beginners.The program below can be used to check whether a String is a Palindrome.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,l,f=0;
char a[20];
printf("\nEnter the string:");
scanf("%s",a);
l=strlen(a);
for(i=0,l=l-1;a[i]!='\0';i++,l--)
{
if(a[i]!=a[l])
{
f=1;
break;
}
}
if(f==0)
printf("String is palindrome");
else
printf("String is not palindrome");
}
No comments:
Post a Comment