include #incluse #define size 5 int array[size]; int top=-1; void push() { int num; if(top == size-2){ printf("Overflow "); } else{ printf("Enter the elements"); scanf("%d ",&num); top+=1; array[top]=num; } } void pop() { if(top==-1) printf("underflow"); else { printf("the popped element is %d",array[top]); top-=1; } } void display() { if(top==-1) { printf("Stack is empty"); } else{ printf("the elements are"); for(int i=top;i>0;i--){ printf("%d",array[i]); } } } int main() { int choice; while(1) { printf(" Operations performed by Stack"); printf(" 1.Push the element 2.Pop the element 3.Display 4.End"); printf(" Enter the choice:"); scanf("%d",&choice); switch(choice) { case 1: push(); break; case 2: pop(); break; case 3: display(); break; case 4: exit(0); default: printf(" Invalid choice!!"); } } } Stack Operation 406 views09:52