we can do this using the string functions
#include%26lt;stdio.h%26gt;
main()
{
char a[20],b[20];
printf("enter a string");
scanf("%s",%26amp;a);
strcpy(b,a);//copies string a to b
strrev(b);//reverses string b
if(strcmp(a,b)==0)//compares if the original and reverse strings are same
printf("\n%s is a palindrome",a);
else
printf("\n%s is not a palindrome",a);
return 0;
}
C program to find wheather the string is palindrome or not..friends please help!!?
Hey thats an excellent trick of finding whether palindrome or not. Good. Keep going..... Report It
Reply:palindrome: It is a word, phrase, number or other sequence of units that has the property of reading the same in either direction.for example:"madam",it can be read in both the directions..
void main()
{
//first read a string A from the key-board using scanf().
// now reverse the given string and store the
//resultant in string C.compare strings A and C using string
//handling functions "strcmp".if it is true then print that string is
//palindrome else print that the string is not palindrome
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment