#include <stdio.h>
#include <stdlib.h>
#define SIZE  10
int count=0;
typedef struct node{
	int value;
	struct stack *next;
	struct stack *prev;
}stack;
stack *bottom=NULL;
stack *top=NULL;
stack *createnode(int a)
{
	stack *newstack;
	newstack=(stack*)calloc(1,sizeof(stack));
	newstack->value=a;
	newstack->prev=NULL;
	newstack->next=NULL;
	return newstack;
}
int isempty()
    {
       if(count==0)
       {return 1;}
       else
       {return 0;}
    }
int isfull()
    {
    	if(count==SIZE)
    	{return 1;}
    	else
    	{return 0;}
    }
void push(int a)
{   if(isfull()==1)
   {
   	printf("overflow condition: stack full");
   }
	else
   {count+=1;
	stack *newstack = createnode(a);
	if(bottom==NULL)
	{ 
	bottom=newstack;
	top=bottom;
	}
	else
	{
		top->next=newstack;
		newstack->prev=top;
		top=newstack;
	}
   }	
}
int peek()
   {
	 printf("%d\n",top->value);
   }
int pop()
    {   if(isempty()==1)
        {
        	printf("underflow condition:empty stack");
        }
        else
       {if(count==1)
        {   int c;
    	    c=top->value;
        	top=NULL;
        	printf("popped value is:%d\n",c);
        	count=count-1;
        }
        else
    	{int c;
    	c=top->value;
		top=top->prev;
		top->next=NULL;
		printf("popped value is:%d\n",c);
		count=count-1;
    	}
       }	
    }

int main(void) {
	stack ruby; int i;
	for(i=0;i<12;i++)
	{push(i);
	 printf("%d\n",count);	
	}
	isfull();
	pop();
	pop();
	pop();
	pop();
	pop();
	pop();
	pop();
	pop();
	pop();
	pop();
	pop();
	int c=isempty();
	printf("%d",c);
	printf("%d",count);
	return 0;
}
