/* Program to check whether a given string is palindrome or not */
#include<stdio.h>
#include<conio.h>
main()
{
char s[1024];
int i,j,l,len;
clrscr();
//accept string
printf("Enter some string:\n");
gets(s);
//check if string is palindrome
for(l=0;s[l]!='\0';l++)
;
len=l;
for(i=0,j=len-1;i<j;i++,j--)
if(s[i]!=s[j])
{
printf("Not Palindrome.\n");
getch();
return;
}
printf("\nString is Palindrome.");
}
#include<stdio.h>
#include<conio.h>
main()
{
char s[1024];
int i,j,l,len;
clrscr();
//accept string
printf("Enter some string:\n");
gets(s);
//check if string is palindrome
for(l=0;s[l]!='\0';l++)
;
len=l;
for(i=0,j=len-1;i<j;i++,j--)
if(s[i]!=s[j])
{
printf("Not Palindrome.\n");
getch();
return;
}
printf("\nString is Palindrome.");
}
0 comments:
Post a Comment