
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Stack
Stack
Stack - Terminologies
Insertion and Deletion in Stack
Insertion and Deletion in Stack
Array Stack
Array Stack
Stack - Terminologies int top = - 1; int stack[10]; void main() { int ch; int val; do { cout << endl << "1: push"; cout << endl << "2: pop"; cout << endl << "3: exit"; cout << endl << "enter choice"; cin >> ch; switch (ch) { case 1: cin>>val; push(val); listStack(); break ; case 2: cout << "data poped= " << pop(); listStack(); break ; case 3: exit(0); } } while (1); }
Push() void push( int data) { if (top+1 == length) { cout << "stack overflow\n Cannot enter new data"; return ; } top++; stack[top] = data; }
listStack() void listStack() { cout << endl << "The stack is" << endl ; for ( int i=top; i>=0; i--) cout << stack[i] << endl; }
Applications of Stack
Expressions
Rules