Below is the code to check whether the given word is Palindrome or not.
#include <string.h>
int main(){
char str[50];
int i, length;
int x=0;
printf("Enter a string:\n");
scanf("%s",&str);
length=strlen(str);
for(i=0;i<length/2;i++){
if (str[i]!=str[length-i-1]){
x=1;
break;
}
}
if(x){
printf("%s is not a palindrome",str);
}else{
printf("%s is a palindrome",str);
}
}
Contents
Output 1:
Enter a string:
madam
madam is a palindrome
Output 2:
Enter a string:
computer
computer is not a palindrome