#include<stdio.h>
#define MAX 10
typedef struct
{
int top;
char item [MAX];
}STR;
void push(STR *QPTR,char ch)
{
if(QPTR->top==MAX-1)
printf("OVERFLOW");
QPTR->item[++QPTR->top]=ch;
}
char pop(STR *QPTR)
{
return (QPTR->item[QPTR->top--]);
}
main()
{
int i,length=0,check;
STR q;
q.top=-1;
char String[MAX],ch;
printf("Please enter a string: ");
scanf("%s", String);
for(i=0;String[i]!='\0';i++)
{
ch=String[i];
push(&q,ch);
length++;
check=1;
}
for(i=0;i<length;i++)
{
ch=pop(&q);
if(String[i]!=ch)
{
check=0;
break;
}
}
if(check==1)
printf("\n\nPallindrome\n\n");
else if(check==0)
printf("\n\nNOT Pallindrome\n\n");
}
0 Comments