Posted by: Sourav | August 13, 2017

Palindrome cheking in C,Sourav Bhattacharya,Kolkata 09748184075


#include<stdio.h>

 

void main()
{
char name[]=”abba”;
char c=’z’;
int length=0;
char reversename[100];
int j=0;
char signal=’T’;
printf(“%s\n”,name);

 

while (c!=’\0′)
{
c=name[length];
length++;

 

}

printf(“the length is %d\n”,length-1);

 

for(int i=(length-2);i>=0;i=i-1)

{

printf(“name[%d] is %c\n”,i,name[i]);
reversename[j]= name[i];
j++;

}
printf(“reversename is %s\n”,reversename);
j=0;
for(j=0;j<=((length)-2);j=j+1)

{
printf(“character reversename[%d]=%c name[%d]=%c is being compared\n”,j,reversename[j],j,name[j]);
if (reversename[j]!=name[j])
{
//printf(“not matched”);
signal=’F’;
}

 

}
if (signal==’T’)
printf(“palindrome\n”);
else
printf(“not pal\n”);

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: