Write a program using string function that determines if the input word is a palindrome. A palindrome is a word that produces the same word when it is reversed.
#include <stdio.h>
#include <string.h>
void isPalindrome(char str[])
{
int i = 0;
int l = strlen(str) - 1;
while (l > i)
{
if (str[i++] != str[l--])
{
printf("%s is Not Palindrome", str);
return;
}
}
printf("%s is palindrome", str);
}
int main()
{
char s[50];
printf("Enter a string ");
scanf("%s",s);
isPalindrome(s);
return 0;
}
Comments
Leave a comment