scanf("%d", &ch); switch(ch) { case 1: if(top < max-1) { printf("\nEnter Stack element : "); scanf("%d", &val); push(val); } else printf("\n Overflow \n"); break; case 2: if(top < 0) printf("\n Stack Underflow \n"); else { val = pop(); printf("\n Popped element is %d\n", val); } break; case 3: view(); break; case 4: exit(0); default: printf("\n Invalid Choice \n"); } } } Output STACK OPERATION 1.PUSH 2.POP 3.VIEW 4.QUIT Choice : 1 Enter Stack element : 12 STACK OPERATION 1.PUSH 2.POP 3.VIEW 4.QUIT Choice : 1 Enter Stack element : 23 STACK OPERATION
scanf("%d", &ch); switch(ch) { case 1: if(top < max-1) { printf("\nEnter Stack element : "); scanf("%d", &val); push(val); } else printf("\n Overflow \n"); break; case 2: if(top < 0) printf("\n Stack Underflow \n"); else { val = pop(); printf("\n Popped element is %d\n", val); } break; case 3: view(); break; case 4: exit(0); default: printf("\n Invalid Choice \n"); } } } Output STACK OPERATION 1.PUSH 2.POP 3.VIEW 4.QUIT Choice : 1 Enter Stack element : 12 STACK OPERATION 1.PUSH 2.POP 3.VIEW 4.QUIT Choice : 1 Enter Stack element : 23 STACK OPERATION
stack-queue.docx