C program to check whether a string is palindrome or not.

 

01 #include <stdio.h>
02 #include <string.h>
03
04 int main()
05 {
06 char a[100], b[100];
07 printf("Enter the string to check if it is a palindromen");
08 gets(a);
09 strcpy(b,a);
10 strrev(b);
11 if( strcmp(a,b) == 0 )
12 printf("Entered string is a palindrome.n");
13 else
14 printf("Entered string is not a palindrome.n");
15 return 0;
16 }
 
 OUTPUT :

(1st Run)

Enter the string to check if it is a palindrome

RADAR

Entered string is a palindrome.


(2nd Run)

Enter the string to check if it is a palindrome

Hello

Entered string is not a palindrome.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.