Write a C program to determine if the given string is a palindrome or not.
Program Code:
#include <stdio.h>
int main() {
int i,j,s1=0,count=0;
charstr[100],temp[100];
printf("Enter a string : ");
gets(str);
for(i=0;str[i]!='\0';i++)
{
s1++;
}
j=0;
for(i=s1-1;i>=0;i--)
{
temp[j] = str[i];
j++;
}
temp[s1] = '\0';
for(i=0;i<s1;i++)
{
if(str[i]==temp[i]&&str[i]!='\0'&&temp[i]!='\0')
{
count++;
}
}
if(count==s1)
{
printf("PALINDROME");
}
else
{
printf("NOT PALINDROME");
}
}
Post A Comment:
0 comments: