//Stack Operation Using Array Implementation.
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void push();
void pop();
void display();
#define SIZE 20
int stk[SIZE],top=-1,data;
main()
{
	int ch;
	char choice='y';
	clrscr();
	while(choice=='y')
	{
//		clrscr();
		printf(" \n\n\n\t\t  S T A C K   O P E R A T I O N\n");
		printf("\t\t\t  1.P U S H\n");
		printf("\t\t\t  2.P O P\n");
		printf("\t\t\t  3.E X I T\n");
		printf("Enter Your choice:");
		scanf("%d",&ch);
		switch(ch)
			{
			case 1:
				push();
				break;
			case 2:
				pop();
				break;
			case 3:
				exit(0);
			default:
				printf("Invalid Choice\n Retry:");
				break;
			}
		display();
		printf("\nDo you Want To Continue:");
		scanf("%c",&choice);
	choice=getchar();
	}
getch();
}
void push()
{
	if(top>SIZE)
	{
		printf("\n Stack Overflow");
		return;
	}
	printf("Enter The Data To Be Pushed:");
	scanf("%d",&data);
	stk[++top]=data;
	return;
}
void pop()
{
	if(top<0)
	{
		printf("\n Stack Underflow");
		return;
	}
	data=stk[top--];
	printf("The Popped Data is: %d",data);
	return;
}
void display()
{
	int i;
	printf("\nThe COntents Of The Stack \ Is:\n");
	for(i=0;i<=top;i++)
		printf("%d\t",stk[i]);
	return ;
}


