C Program to find whether a string is palindrome or not.

/*   Write a C Program to find whether a string is palindrome or not.  */
===================================================
#include<stdio.h>
#include<conio.h>
void main()
{
char s1[20],s2[20];
clrscr();
printf(“enter a string: ”);
scanf(“%s”,s1);
strcpy(s2,s1);
strrev(s2);
if(strcmp(s1,s2)==0)
printf(“string is a palindrome”);
else
printf(“not a palindrome string”);
getch();
}

Output:
======
enter a string: abc
not a palindrome string

No comments: