#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define max 8

struct stack{ int ele[max],top1,top2;};

void push1(struct stack *s,int a)
{
 s->ele[++s->top1]=a;
}

void disp1(struct stack s)
{
 int i;
 for(i=s.top1;i>=0;i--) printf("\n%d",s.ele[i]);
}

int pop1(struct stack *s)
{
 return s->ele[s->top1--];
}

void makeempty1(struct stack *s)
{
 s->top1=-1;
 printf("BOTTOM STACK IS MADE EMPTY");
}

void push2(struct stack *s,int a)
{
 s->ele[--s->top2]=a;
}

void disp2(struct stack s)
{
 int i;
 for(i=s.top2;i<max;i++) printf("\n%d",s.ele[i]);
}

int pop2(struct stack *s)
{
 return s->ele[s->top2++];
}

void makeempty2(struct stack *s)
{
 s->top2=-1;
 printf("TOP STACK IS MADE EMPTY");
}

void main()
{
  int n,a;
  struct stack s={{0},-1,max};
 while(1)
 {
  clrscr();
  printf("1.PUSH1\n 2.POP1\n 3.DISPLAY1 \n 4.MAKE-EMPTY1\n 5.PUSH2\n 6.POP2\n 7.DISPLAY2 \n 8.MAKE-EMPTY2\n9.EXIT\n");
  printf("ENTER UR CHOICE FROM 1-9\n");  scanf("%d",&n);
  if(n==9) break;
  switch(n)
  {   case 1:
	  if(s.top1+1==s.top2)  printf("\n Overflow:\n");
	  else
	  {
	   printf("ENTER ANY NUMBER:\n");
	   scanf("%d",&a);
	   push1(&s,a);
	  }
	  break;
   case 2:
	  if(s.top1==-1)
	   printf("\n Underflow");
	  else printf("POPPED ELEMENT IS %d",pop1(&s));
	  break;
   case 3:
	  if(s.top1==-1)
	  {
	   printf("\n Underflow");
	  }
	  else
	  disp1(s);
	  break;
   case 4:
	  makeempty1(&s);
	  break;
   case 5:
	  if(s.top1+1==s.top2)  printf("\n Overflow:\n");
	  else
	  {
	   printf("ENTER ANY NUMBER:\n");
	   scanf("%d",&a);
	   push2(&s,a);
	  }
	  break;
   case 6:
	  if(s.top2==max)
	   printf("\n Underflow");
	  else printf("POPPED ELEMENT IS %d",pop2(&s));
	  break;
   case 7:
	  if(s.top2==max)
	  {
	   printf("\n Underflow");
	  }
	  else
	  disp2(s);
	  break;
   case 8:
	  makeempty2(&s);
	  break;
default: printf("\nInvalid option!");
   }
   getch();
 }
 getch();
}