#include<stdio.h>
int string_palindrome(int l,char s[])
{ int i=0;
for(i=0; i<l; i++)
{
if(s[i]!=s[l-i-1])
{ return 1;
break;
}
return 0;
}
}
int string_length(char s[])
{
int j=0;
while(s[j]!='\0')
{
j++;
}
return j;
}
int main()
{ char a[100];
int l,flag;
printf("Enter a string\n");
gets(a);
l=string_length(a);
flag=string_palindrome(l,a);
if(flag==0)
{
printf("String is palindrome");
} else
{
printf("String is not palindrome");
}
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter a string
malayalam
String is palindrome