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

struct stack { int top; int ele[max];} ;

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

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

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

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

void main()
{
  int n,a;
  struct stack s;
  s.top=-1;
 while(1)
 {
  clrscr();
  printf("1.PUSH\n 2.POP\n 3.DISPLAY \n 4.MAKE-EMPTY\n 5.EXIT\n");
  printf("ENTER UR CHOICE 1/2/3/4/5\n");  scanf("%d",&n);
  if(n==5) break;
  switch(n)
  {   case 1:
	  if(s.top>=max-1)  printf("\n Overflow:\n");
	  else
	  {
	   printf("ENTER ANY NUMBER:\n");
	   scanf("%d",&a);
	   push(&s,a);
	  }
	  break;
   case 2:
	  if(s.top==-1)
	   printf("\n Underflow");
	  else printf("POPPED ELEMENT IS %d",pop(&s));
	  break;
   case 3:
	  if(s.top==-1)  printf("\n Underflow");
	  else  disp(s);
	  break;
   case 4:
	  makeempty(&s);
	  break;
   default: printf("\nInvalid option!");
   }
   getch();
 }
 getch();
}
