C program to check given string is palindrome or not
program code
#include<stdio.h>#include<string.h>
main()
{
char str[100];
int i=0,j;
printf("\n enter any string:");
gets(str);
j=strlen(str)-1;
while(i<=j/2)
{
if(str[i]==str[j])
{
i++;
j--;
}
else
break;
}
if(i>=j)
printf("\n given string is palindrome:");
else
printf("\n given string is not palindrome:");
}
program output: -
first output is to show the given string is palindrome
second output is to show the given string is not palindrome
Comments
Post a Comment
please subscribe my blog and let me suggest how I improve this site