C PROGRAM TO FIND WHETHER STRING IS A PALINDROME
C PROGRAM TO FIND WHETHER STRING IS PALINDROME :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include<stdio.h> #include<string.h> main() { char str1[25],str2[25]; printf("\n *** C Programs Blog ***"); printf("\n >>> C Program to find whether string is Palindrome <<<"); printf("\n\n Enter the string: "); scanf("%s",str1); strcpy(str2,str1); //copying str1 in str2 strrev(str2); //reversing str2 if(strcmp(str1,str2) == 0) //checking whether str1 and atr2 are same { printf("\n Entered string " %s " is a Palindrome",str1); } else { printf("\n Entered string " %s " is not a Palindrome",str1); } getch(); } |