Pages

Monday, June 13, 2016

C Program to check given string is Palindrome or not.


// C Program to check given string is Palindrome or not.

#include <stdio.h>
#include <string.h>

void main()
{
   char a[10], b[10];

   printf("Enter your string:\n");
   gets(a);

   strcpy(b,a);
   strrev(b);

   if (strcmp(a,b) == 0)
      printf("Entered string is a palindrome.\n");
   else
      printf("Entered string is not a palindrome.\n");
}

Output of program

Enter your string:
ABA
Entered string is a palindrome.

No comments:

Post a Comment