//WAP TO CHECK WHETHER THE ENTERED STRING IS PALLINDROME OR NOT.
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char a[20];
char b[20];
char temp[20];
char temp1[20];
char ch='y';
int i;
clrscr();
do
{
fflush(stdin);
puts("\n\nENTER THE STRING:");
gets(a);
printf("\n\nENTERED STRING IS:");
puts(a);
strcpy(temp1,a);
strrev(a);
strcpy(temp,a);
for(i=0;a[i]!='\0';i++)
if(temp1[i]==temp[i])
{
printf("\n\nENTERED STRING IS A PALLINDROME");
break;
}
else
{
printf("\n\nENTERED STRING IS NOT A PALLINDROME");
break;
}
puts("\n\nDO YOU WANT TO CONTINUE?");
scanf("%s",&ch);
}while(ch=='y'||ch=='Y');
puts("\n\nBYE!!BYE!!\n\nPROGRAMMER:ABHISHEK WADHWA");
getch();
}
/*-----------------------------------------------------------
OUTPUT
------------------------------------------------------------
ENTER THE STRING:
NAMAN
ENTERED STRING IS:NAMAN
ENTERED STRING IS A PALLINDROME
DO YOU WANT TO CONTINUE?
Y
ENTER THE STRING:
ABHISHEK
ENTERED STRING IS:ABHISHEK
ENTERED STRING IS NOT A PALLINDROME
DO YOU WANT TO CONTINUE?
N
BYE!!BYE!!
PROGRAMMER:ABHISHEK WADHWA
*/
No comments:
Post a Comment