C palindrome program / c program to find a string is palindrome or not

c programming tutorial implement palindrome program or find a string is palindrome or not

palindrome.c

#include <stdio.h>
#include <string.h>
 
int main()
{
   char a[100], b[100];
 
   printf("Enter the string to check if it is a palindrome\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");
 
   return 0;
}

Output


Enter the string to check if it is a palindrom
lol
Entered string is a palindrome.

0 comments:

Post a Comment

My Instagram