#include
#include
#define maxstak 5
int top=-1
int stak[maxstak-1];
void push();
void pop();
void display();
main()
{
int g;
while(1)
{
printf("\n 1 : Push\n 2 : Pop\n 3 : Display \n 4 : Exit\n Enter your choice = ");
scanf("%d",&g);
switch(g)
{
case 1 : push();
break;
case 2 : pop();
break;
case 3 : display();
break;
case 4 :
exit (0);
default : printf("\nYou enter wrong choice.\n ");
}
}
return 0;
}//End of main.
void push()
{
int item;
if(top == maxstak-1)
{
printf("\n Stack Over flow. \n");
}
else
{
printf("\n Inter the element of stak = ",item);
scanf("%d",&item);
top = top+1;
stak[top] = item;
}
}//End of push.
void pop()
{
int item;
if(top == -1)
{
printf("\n Stack is under flow. \n");
}
else
{
item = stak[top];
top = top-1;
printf("\n Deleted item is = %d",item);
}
}//End of pop.
void display()
{
int i;
if(top == -1)
{
printf(" Stack is under flow");
}
else
{
printf("\n Elements in stack are:-\n\t\t");
for(i=top;i>=0;i--)
{
printf("%d\n\t\t",stak[i]);
}
}
}//End of display.
Copyright © 2011 - All Rights Reserved - Softron.in
Template by Softron Technology