#include #include void push(int stack[], int *top, int value) { if(*top < 4 ) { *top = *top + 1; stack[*top] = value; printf("\nStack element should be less than four\n"); } else { printf("\nThe stack is full can not push a value\n"); exit(0); } } void pop(int stack[], int *top, int * value) { if(*top >= 0 ) { *value = stack[*top]; *top = *top - 1; } else { printf("\nThe stack is empty can not pop a value\n"); exit(0); } } void main() { int stack[4]; int top = 0; int n,value; do { do { printf("\nEnter the element to be pushed\n"); scanf("%d",&value); push(stack,&top,value); printf("\nEnter 1 to continue and other key to pop\n"); scanf("%d",&n); printf(""); } while(n == 1); printf("\nEnter 1 to pop an element\n"); scanf("%d",&n); while( n == 1) { pop(stack,&top,&value); printf("\nThe value poped is %d",value); printf("\nEnter 1 to pop an element\n"); scanf("%d",&n); } printf("\nEnter 1 to continue and other key to push\n"); scanf("%d",&n); } while(n == 1); }