#include <stdio.
h>
#define size 10
void find_peek();
void push(int);
void pop();
void display();
int stack[size];
int var,cho,top=0;
void main()
{
clrscr();
do{
printf("MAINMENU\[Link] \[Link] \n3.Find_peek \[Link]\[Link]. \n");
printf("Enter the choice :");
scanf("%d",&cho);
switch(cho){
case 1:
printf("Enter the variable:");
scanf("%d",&var);
push(var);
break;
case 2:
pop();
break;
case 3:
find_peek();
break;
case 4:
display();
break;
}
}while(cho!=5);
}
void push(int ele)
{
if(top>=size)
printf("The stack is overflow\n");
else
stack[top++]=ele;
}
void pop()
{
if(top==0)
printf("The stack is underflow\n");
else
printf("The popped element is %d\n",stack[--top]);
}
void find_peek()
{
if(top==0)
printf("The stack is empty\n");
else
printf("The peek element is %d\n",stack[top-1]);
}
void display()
{
int i;
if(top==0)
printf("The stack is empty\n");
else{
for(i=top-1;i>=0;i--)
printf("\n%d",stack[i]);
printf("\n");
}
}