Tuesday, December 6, 2011

Write a C program to check given string is palindrome or not

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
 char a[10],b[10];
 clrscr();
 printf("\nEnter a string: ");
 gets(a);
 strcpy(b,a);
 strrev(b);
 if(strcmp(a,b)==0)
 {
  printf("%s is palindrom",a);
 }
 else
 {
  printf("%s is not palindrom",a);
 }
 getch();
}

No comments:

Post a Comment