C String Programs

C Program to Check if a Given String is Palindrome

C Program to Check if a Given String is Palindrome – Given a string, we write a c function to check whether that string is palindrome or not.

A string is said to palindrome if the string and it’s reverse are equal. For example, “aa”,”abbccbba” are palindromes where as, “aac” , “abcd” are not.

Algorithm for – C Program to Check if a Given String is Palindrome

Following is the C implementation to check if the string is palindrome or not :

#include
#include
void isPalindrome(char string[])
{
int start=0;
int end=strlen(string)-1;
while(end>start)
{
if(string[start++]!=string[end--])
{
printf("\nString %s is not a palindrome",string);
return;
}
}
printf("\n Given string %s is a palindrome",string);
}
int main()
{
isPalindrome("abaca");
isPalindrome("aabbccaa");
return(0);
}

C Program to Check if a Given String is Palindrome

Summary
C Program to Check if a Given String is Palindrome
Article Name
C Program to Check if a Given String is Palindrome
Description
C Program to Check if a Given String is Palindrome - Given a string, we write a c function to check whether that string is palindrome or not.
Author
Publisher Name
Scanfcode
Publisher Logo