Skip to main content

Solve-write C program to check given string is palindrome or not

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