Source Code Example to check whether the Word is Palindrome or not
#include <stdio.h>
#include <string.h>
int main()
{
char one[200]={""};
char two[200];
printf("Enter the word you want to check.");
scanf("%s",one);
strcpy(two, one);
strrev(two);
if(strcmp(one, two) == 0)
printf("The entered string %s is a palindrome.\n", one);
else
printf("The entered string %s is not a palindrome.\n", one);
printf("The reverse of the string is %s.\n", two);
}
Source Code Example to check whether the Number is Palindrome or not
#include <stdio.h>int main()
{
int number, reverse = 0, temp;
printf("Enter number:");
scanf("%d", &number);
temp = number;
while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp / 10;
}
if ( number == reverse )
printf("The number is a Palindrome number.\n");
else
printf("The number is not a Palindrome number.\n");
}
Enjoy coding :)
No comments:
Post a Comment