/* Name: PUSH And POP Copyright: www.micted.weebly.com Author:Nawaraj Ghimire ([email protected]) Date: 28/10/13 12:49 Description:PUSH and POP operation in stack */ #include<conio.h> #include<stdio.h> #include<process.h> void push(); void pop(); void display(); int stack[5],tos=-1; void main() { int option; //clrscr(); do {printf("\n 1for push \t2for pop \t 3 for Display \t 4 for exit \n\n Enter your choice:"); scanf("%d",&option); switch(option) {case 1: push(); break; case 2: pop(); break; case 3: display(); break; case 4: exit(0); } } while(option!=4); getch(); } void push() {int item; if(tos==4) printf("\n stack over flow"); else { printf("\nEnter Value" ); scanf("%d",&item); tos=tos+1; stack[tos]=item; printf("\n %d is in intered sucessfully",item); } } void pop() {int item; if(tos==-1) printf("\n stack under floe"); else {item=stack[tos]; tos=tos-1; printf("%d is removed sucesfully", item); } } void display() { int i; if(tos==-1) printf("stack is empty"); else { for(i=tos;i>=0;i--) printf("\n %d", stack[i]); } }