Tuesday, February 22, 2011

Palindrome Program!!

Palindrome is a word which reads the same from both sides. Example is MADAM. This program uses the built-in functions from the directory 'string.h' , to determine whether the given string is a palindrome or not. 

The command 'strrev' reverses the string and 'strcpy' copies one string to another for comparision.


PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[80],b[80];
clrscr();
printf("\nEnter the String:");
gets(a);
strcpy(b,a);
strrev(b);
if(strcmp(a,b)==0)
printf("\nThe String is Palindrome");
else
printf("\nThe String is Non-Palindrome");
getch();
}


No comments:

Post a Comment