TO find whether the given string is a palindrome or not */
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char string[90];
int i,j,len,flag=0;
clrscr();
printf("\nEnter the string to be checked for Palindrome:\n");
gets(string);
len=strlen(string); // or for(len=0;string[len]!='\0';len++);
for(i=0,j=len-1;i<len/2;i++,j--)
{
if(string[i]!=string[j]) // check whether palindrome
flag=1;
}
if(flag==1)
printf("\nString is not a Palindrome");
else
printf("\nString is a Palindrome");
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char string[90];
int i,j,len,flag=0;
clrscr();
printf("\nEnter the string to be checked for Palindrome:\n");
gets(string);
len=strlen(string); // or for(len=0;string[len]!='\0';len++);
for(i=0,j=len-1;i<len/2;i++,j--)
{
if(string[i]!=string[j]) // check whether palindrome
flag=1;
}
if(flag==1)
printf("\nString is not a Palindrome");
else
printf("\nString is a Palindrome");
getch();
}