Given a string, check whether it is a palindrome or not.
For Example:
If the input is "malayalam", the reverse of the string would give you the same string.
Hence, output "malayalam" is a palindrome.
For Example:
If the input is "malayalam", the reverse of the string would give you the same string.
Hence, output "malayalam" is a palindrome.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
char *s,*v;
int len,i;
s=(char*)malloc(sizeof(char));
v=(char*)malloc(sizeof(char));
scanf("%s",s);
len=strlen(s)-1;
i=0;
while(len>=0)
{
*(v+i)=*(s+len);
i++,len--;
}
v[++i]='\0';
printf("%s is ",s);
if(strcmp(s,v)==0)
printf("a palindrome of %s",v);
else
printf("not a palindrome of %s",v);
return 0;
}