PROGRAM TO CHECK A STRING IS PALINDROME OR NOT
/*PROGRAM TO CHECK A STRING IS PALINDROME OR NOT */
#include<stdio.h>
#include<conio.h>
void main()
{
intl,i=0,p=0;
char st[30];
clrscr();
printf("Enter any string: ");
scanf("%[^\n]",st);
while(st[i]!='\0')
i++;
l=i;
for(i=0;i<l/2;i++)
if(st[i]!=st[l-i-1])
{
p=1;
break;
}
if(p==0)
printf("The string is palindrome");
else
printf("The string is not palindrome");
getch();
}
Output :-
Output 1 :-
Output 2 :-
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment