3
3
3
h>
#include<conio.h>
#define MAX 4
/* PUSH FUNCTION */
void push(int stack[], int item)
{
if (top == (MAX-1))
printf("\n\nStack is Overflow");
else
{
stack[++top] = item;
status++;
}
}
/* POP FUNCTION */
int pop(int stack[])
{
int ret;
if(top == -1)
printf("\n\nStack is Underflow");
else
{
ret = stack[top--];
status--;
printf("\nPopped element is %d", ret);
}
return ret;
}
void main()
{
do{
printf("\n\n----MAIN MENU----\n");
printf("1. PUSH (Insert) in the Stack");
printf("\n2. POP (Delete) from the Stack");
printf("\n3. PALINDROME check using Stack");
printf("\n4. Exit (End the Execution)");
printf("\nEnter Your Choice: ");
scanf("%d", &ch);
switch(ch){
case 1:
printf("\nEnter an element to be pushed: ");
scanf("%d", &item);
push(stack, item);
display(stack);
break;
case 2:
item = pop(stack);
display(stack);
break;
case 3:
palindrome(stack);
break;
case 4:
exit(0);
break;
default:
printf("\nEND OF EXECUTION");
}// end switch
} while (ch != 4);
getch();
}