Introduction
The below program shows a string is palindrome or not. This is done using string functions. string copy and string reverse functions are used to check a word palindrome or not. mom is a palindrome. car is not a palindrome. Here the entered string is copied into another variable and reverse of this string is compared with original string, to get a palindrome.
#include<stdio.h> #include<conio.h> #include<string.h> main() { char a[100],b[100]; printf("/n Enter the string to check if it is a palindrome"); gets(a); strcpy(b,a); strrev(b); if(strcmp(a,b)==0) printf("/n Entered string is a palindrome"); else printf("/n Entered string is not a palindrome"); return 0; }
Comments/Suggestions are invited. Happy coding......!
Comments Post a Comment