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 string\n");
scanf("%[^\n]",string);
len=strlen(string);
// logic for checking palindrome
for(i=0;i<len/2;i++)
{
if(string[i]!=string[len-i-1])
break;
}
if(i==len/2)
printf("Palindromic string\n");
else
printf("String is not a Palindromic\n");
return 0;
}
Output:-
Enter a string
Easycodingzone
string is not a palindromic
0 Comments