Social Icons

Friday, 14 February 2014

Program to check whether given string is palindrome or not

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
int i,j,f=1,len;
char str[30];
clrscr();
printf("\n Enter any string : ");
gets(str);
len=strlen(str);

for(i=0,j=len-1;i<len/2;++i,--j)
if(str[i]!=str[j])
{
f=0;
break;
}
if(f)
printf("\n String is palindrome");
else
printf("\n String is not palindrome");
getch();
}

                                                  Output



No comments:

Post a Comment