Wednesday, 29 October 2014

Palindrome ( with built-in functions )

Aim:
To check given string is palindrome or not.

Program:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main ()
  {
     char str[80],revstr[80];
     clrscr ( );
printf("\nEnter a string:");
   scanf("%s",&str)
   strcpy(revstr,str);
   strrev(revstr);
if(!strcmp(str,revstr))
   printf("\nGiven string '%s' is Palindrome",str);
else
   printf("\nGiven string '%s' is not Palindrome",str);
}

Output:
Enter a string: medem
Given string 'medem' is Palindrome

2 comments: