Wednesday, February 11, 2015

C program to check whether given string is palindrome or not


C program to check whether given string is palindrome or not

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

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

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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.