C Program to check for a Palindrome Word/Number [Simple]
This is a simple C program which can check whether the word or number entered by the user is palindrome or not. Rather than using longer mathematical algorithms, it simple uses 3 direct commands that are:
- strcpy()
- strrev()
- strcmp()
/*
Program to check for palindrome number/word
Programmer: Amit Biswal
URL : www.123mylist.com
*/
#include <stdio.h>
#include <conio.h>
int main()
{
char word[10],temp[10];
printf("Enter the word/number to be checked for Palindrome\n");
gets(word);
strcpy(temp,word);
strrev(temp);
if(!strcmp(word,temp))
printf("\nPALINDROME");
else
printf("\nNOT PALINDROME");
getch();
return 0;
}
Post a Comment