C program to check whether a string is palindrome or not using string functions.
C program to check whether a string is palindrome or not using string functions.
#include <stdio.h>
#include <string.h>
#define MAX 100
int main()
{
char text[MAX], res[MAX];
int test;
printf("Enter any string: ");
gets(text);
strcpy(res, text);
strrev(res);
test = strcmp(text, res);
if(test == 0)
{
printf("\n Enter String is Palindrome.");
}
else
{
printf("\n Enter String is Not Palindrome.");
}
return 0;
}
Output:
Enter any string: rama
String is Not Palindrome.
Enter any string: madam
String is Palindrome.