C Program to Check Given String is Palindrome or Not

How to write a C Program to Check Given String is Palindrome or Not in C Programming Language ?


Solution:

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4. void main()
  5. {
  6.  char a[10],b[10];
  7.  clrscr();
  8.  printf("\nEnter a string: ");
  9.  gets(a);
  10.  strcpy(b,a);
  11.  strrev(b);
  12.  if(strcmp(a,b)==0)
  13.  {
  14.   printf("%s is palindrom",a);
  15.  }
  16.  else
  17.  {
  18.   printf("%s is not palindrom",a);
  19.  }
  20.  getch();
  21. }


Learn More :