#include<stdio.h>
#include<conio.h>
#define max 5
void push();
void pop();
void peep();
int top=-1,item,stack[max];
void main()
{
int ch;
clrscr();
do
{
printf("\n1. Push\n2. Pop\n3. Peep\n4. Exit\n\n");
printf("Enter Your Choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
peep();
break;
default:
printf("\nSorry ( Enter Between 1 To 4 ) !!\n\n");
}
}while(ch!=4);
}
void push()
{
if(top==max)
{
printf("Stack Overflow");
getch();
}
else
{
printf("Enter a no : ");
scanf("%d",&item);
top=top+1;
stack[top]=item;
}
}
void pop()
{
clrscr();
if(top==-1)
{
printf("Stack Empty");
getch();
}
else
{
item=stack[top];
top=top-1;
printf("DELETE ITEM IS : %d",item);
getch();
}
}
void peep()
{
int i;
clrscr();
if(top==-1)
printf("Stack Empty");
else
for(i=top;i>=0;i--)
{
printf(" %d \n",stack[i]);
}
getch();
clrscr();
}