Write a program in C to check whether the given string is a palindrome or not

 What is palindrome string:- 

                                                   A string is said to be palindrome if string is equal to it’s reverse.

example:-    abba is a palindrome because it is equal to it’s reverse.

                    abcd is not a palindrome.

Code:-

#include<stdio.h>
#include<string.h>
int main()
{
int i,len;
char string[50];
printf(“Enter a stringn”);
scanf(“%[^n]”,string);
len=strlen(string);

// logic for checking palindrome
for(i=0;i<len/2;i++)
{
if(string[i]!=string[leni1])
break;
}
if(i==len/2)
printf(“Palindromic stringn”);
else
printf(“String is not a Palindromicn”);
return 0;
}

Output:- 

Enter a string

Easycodingzone

string is not a palindromic



Leave a Reply

Your email address will not be published.