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");
}
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: