C PROGRAM TO CHECK WHETHER A STRING IS PALINDROME OR NOT
An String is a palindrome if the reverse of that string is equal to the original string.
The following program check the given number is palindrome or not:
Example program:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char word[20],copyword[20];
int l;
clrscr();
printf("enter the string:");
scanf("%s",&word);
strcpy(copyword,word);
strrev(copyword);
l=strcmp(copyword,word);
if(l==0)
{
printf("it is a palindrome");
}
else
{
printf("it is not a palindrome");
}
getch();
}
Output:
Leave a Comment