Palindrome in c

Basic concept behind Palindrome


Implementation in c program

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[20],str2[20],flag;
int i,l,j=0;
clrscr();
printf("Enter string:");
scanf("%s",str1);
l=strlen(str1);
for(i=0;i<l;i++)
{
printf("%c",str1[i]);
str2[j]=str1[i];
j++;
}
printf("\nReverse string is:");
for(j=l-1;j>=0;j--)
{
printf("%c",str2[j]);
}
if(strcmp(str1,str2)==0)
{
printf("\npalindrom");
}
else
{
printf("\nnot palindsrom");
}
getch();

}

Comments

Popular posts from this blog

Tips 01) self introduction in an interview

Computer Science Terminology

Why Failure Is Good for Success