100 Most Important C# Programs
41. Program to accept a string and check the given string is palindrome or not .
Code:
# include <stdio.h>
# include <conio.h>
main( )
{
int i,lim,c,check=1;
char word[80];
clrscr( );
printf(“ enter a string”);
for(i=0;i<80 && ((word [i]=
getchar())!=’\n’);i++);
lim=i-1;
c=lim/2;
for(i=0;i<=0;i++,lim--)
if(word[i]!= word[lim])
{
check=0;
break;
}
if(check= =1)
printf(“the given string is palindrome “);
else
printf(“ not palindrome”);
getch( );
}