#include<stdio.
h>
#include<stdlib.h>
#include<string.h>
#define MAX 5
int stack[MAX],top=-1;
char stack1[MAX],top1=-1;
void push()
int ele;
if(top<MAX-1)
printf("enter the value to be inserted into the stack:\n");
scanf("%d",&ele);
stack[++top]=ele;
else
printf("\n stack is full\n");
return;
void pop()
if(top!=-1)
printf("\n the element deleted from the stack is:%d\n",stack[top--]);
else
printf("\n stack is empty\n");
return;
void palindrome()
{
int i,count=0,len;
char str[100];
printf("\n entertring to check whether it is palindrome or not:");
scanf("%s",str);
len=strlen(str);
for(i=0;i<len;i++)
stack1[++top1]=str[i];
for(i=0;i<len;i++)
if(str[i]==stack1[top1--])
count++;
if(count==len)
printf("\n %s is a palindrome string\n",str);
else
printf("\n %s is not a palindrome string\n",str);
return;
void check()
if(top>=MAX-1)
printf("stack is overflow\n");
else if(top==-1)
printf("stack is underflow\n");
else
printf("stack operation can be performed\n");
void display()
{
int i;
if(top==-1)
printf("\n stack is empty\n");
else
printf("\n elements in the stack are\n");
for(i=top;i>=0;--i)
printf("|%d|\n",stack[i]);
return;
void main()
int choice;
while(1)
printf("\n STACK OPERATIONS\n");
printf("\n 1:push\t2:pop\t3:palindrome\t4:check\t5:display\t6:exit\n");
printf("\n enter your choice[1/2/3/4/5/6]:");
scanf("%d",&choice);
switch(choice)
case 1: push();break;
case 2: pop();break;
case 3: palindrome();break;
case 4: check();break;
case 5: display();break;
case 6: exit(0);
default: printf("invaild choice\n");
}
return;