palindrome program using c
palindrome program
#include<stdio.h>#include<conio.h>
#include<math.h>
#include<string.h>
void main()
{
int i,j,len,flag=0;
char str[20];
clrscr();
printf("Enter the string:"):
scanf("%s",str);
len=strlen(str);
j=len-1;
for(i=0;i<(len/2);i++)
{
if(str[i]!=str[j])
{
flag=0;
break;
}
j--;
flag=1;
}
if(flag==1)
printf("string is palindrome");
else
printf("string is not palindrome");
getch();
}
Output
Enter the string: AMMAString is palindrome
No comments: