Posted by: Sourav | September 6, 2014

Palindrome in C


#include<stdio.h>
#include<conio.h>
void main()
{
char soumita[100];
char reverse[100];
int a,b=0,c=0,d=0;
clrscr();
printf(“Enter a string”);
scanf(“%s”,&soumita);

 for(a=0;a<100;a++)
{
if((soumita[a]!=”) )
{
b=b+1; }
else
{
break;
}
}
for(a=(b-1);a>=0;a–)
{
reverse[c]=soumita[a];
c++;
}
for(a=0;a<b;a++)
{
if(soumita[a]!=reverse[a])
{
d=1;
break;
}
}
if(d==1)
{
printf(“\tNot”);
}
else{
printf(“\tPal”);
}

getch();
}

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: