Sunday, July 26, 2015

string_palindrome

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

int main()
{
   char a[100],b[100];
   while(1){
   printf("Enter the string to check if it is a palindrome:");
   scanf("%s",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");
      break;
   }
   }

   return 0;
}

No comments:

Post a Comment