#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#define max 100
char a[max][max];
int top = -1;
char x[max];
int isempty() ;
int isfull() ;
void push() ;
int pop() ;
void display() ;
int main()
{
int ch;
do
{
printf("\n 1. Push");
printf("\n 2. Pop");
printf("\n 3. Display");
printf("\n 4. Exit\n");
scanf("%d",&ch);
switch (ch) {
case 1:
push();
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
break;
default:
printf("Invalid Choice");
break;
}
}while(ch!=4);
return 0;
}
int isfull(){
if ( (top == max-1))
{
return 1;
}
else
{
return 0;
}
}
int isempty(){
if((top==-1))
{
return 1;
}
else
{
return 0;
}
}
void push(){
if (isfull())
{
printf("Stack is full");
}
else
{
printf("Enter element to add");
scanf("%s",x);
top++;
strcpy(a[top],x);
}
}
int pop(){
if(isempty())
{
printf("Stack is empty");
exit(0);
}
else{
strcpy(x,a[top]);
printf("%s",x);
top--;
}
}
void display()
{
if(isempty())
{
printf("NO data to display");
exit(0);
}
else
{
int i;
for(i=0;i<top+1;i++)
{
printf("%s \n",a[i]);
}
}
}