SlideShare a Scribd company logo
1 of 19
Stacks
• A stack is a container of objects that are inserted
and removed according to the last-in first-out
(LIFO) principle. In the pushdown stacks only
two operations are allowed: push the item into
the stack, and pop the item out of the stack.
Important Hints
• An array is a random access data structure,
where each element can be accessed directly and
in constant time. A typical illustration of random
access is a book - each page of the book can be
open independently of others. Random access is
critical to many algorithms, for example binary
search.
In Programming, a special type of data
structure in which items are removed in the
reverse order from that in which they are
added, so the most recently added item is the
first one removed. This is also called last-in,
first-out (LIFO).Adding an item to a stack is
called pushing. Removing an item from a stack
is called popping.
Applications
• The simplest application of a stack is to reverse a
word. You push a given word to stack - letter by
letter - and then pop letters from the stack.
• Another application is an "undo" mechanism in
text editors; this operation is accomplished by
keeping all text changes in a stack.
• Backtracking. This is a process when you need
to access the most recent data element in a
series of elements.
Backtracking
• Once you reach a dead end, you must
backtrack. But backtrack to where? to the
previous choice point. Therefore, at each
choice point you store on a stack all possible
choices. Then backtracking simply means
popping a next choice from the stack.
Language processing:
• space for parameters and local variables is
created internally using a stack.
• compiler's syntax check for matching braces is
implemented by using stack.
• support for recursion
Stack Operations using Array
• Step 1: Include all the header files which are
used in the program and define a
constant 'SIZE' with specific value.
• Step 2: Declare all the functions used in stack
implementation.
• Step 3: Create a one dimensional array with fixed
size (int stack[SIZE])
• Step 4: Define a integer variable 'top' and
initialize with '-1'. (int top = -1)
• Step 5: In main method display menu with list
of operations and make suitable function calls
to perform operation selected by the user on
the stack.
push(value) - Inserting value in the stack
• In a stack, push() is a function used to insert
an element into the stack. In a stack, the new
element is always inserted at top position.
Push function takes one integer value as
parameter and inserts that value into the
stack. We can use the following steps to push
an element on to the stack...
• Step 1: Check whether stack is FULL. (top ==
SIZE-1)
• Step 2: If it is FULL, then display "Stack is FULL!!!
Insertion is not possible!!!" and terminate the
function.
• Step 3: If it is NOT FULL, then
increment top value by one (top++) and set
stack[top] to value (stack[top] = value).
pop() - Delete a value from the Stack
• In a stack, pop() is a function used to delete an
element from the stack. In a stack, the element
is always deleted from top position. Pop function
does not take any value as parameter. We can
use the following steps to pop an element from
the stack...
• Step 1: Check whether stack is EMPTY. (top ==
-1)
• Step 2: If it is EMPTY, then display "Stack is
EMPTY!!! Deletion is not possible!!!" and
terminate the function.
• Step 3: If it is NOT EMPTY, then
delete stack[top] and decrement top value by
one (top--).
display() - Displays the elements of a Stack
• We can use the following steps to display the
elements of a stack...
• Step 1: Check whether stack is EMPTY. (top == -1)
• Step 2: If it is EMPTY, then display "Stack is
EMPTY!!!" and terminate the function.
• Step 3: If it is NOT EMPTY, then define a variable 'i'
and initialize with top. Display stack[i] value and
decrement i value by one (i--).
• Step 3: Repeat above step until i value becomes '0'.
Program
• #include<stdio.h>
• #include<conio.h>
• #define SIZE 10
• void push(int);
• void pop();
• void display();
• int stack[SIZE], top = -1;
• void push(int value)
• {
• if(top == SIZE-1)
• printf("nStack is Full!!! Insertion is not possible!");
• else
• {
• top++;
• stack[top] = value;
• printf("nInsertion success!!!");
• }
• }
• void pop()
• {
• if(top == -1)
• printf("nStack is Empty! Deletion is not possible!");
• else
• {
• printf("nDeleted : %d", stack[top]);
• top--;
• }
• }
• void display()
• {
• if(top == -1)
• printf("nStack is Empty!!!");
• else
• {
• int i;
• printf("nStack elements are:n");
• for(i=top; i>=0; i--)
• printf("%dn",stack[i]);
• }
• }

More Related Content

What's hot

Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
Jsaddam Hussain
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 

What's hot (20)

2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
Odersky week1 notes
Odersky week1 notesOdersky week1 notes
Odersky week1 notes
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
Data Structures 2
Data Structures 2Data Structures 2
Data Structures 2
 
Stack
StackStack
Stack
 
Stack converted
Stack convertedStack converted
Stack converted
 
Queue-Data Structure
Queue-Data StructureQueue-Data Structure
Queue-Data Structure
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Quicksort Algorithm..simply defined through animations..!!
Quicksort Algorithm..simply defined through animations..!!Quicksort Algorithm..simply defined through animations..!!
Quicksort Algorithm..simply defined through animations..!!
 
Lect 17-18 Zaheer Abbas
Lect 17-18 Zaheer AbbasLect 17-18 Zaheer Abbas
Lect 17-18 Zaheer Abbas
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structure
 
D404 ex-5-1-1
D404 ex-5-1-1D404 ex-5-1-1
D404 ex-5-1-1
 
Circular queue
Circular queueCircular queue
Circular queue
 
Insertion sort
Insertion sort Insertion sort
Insertion sort
 
Data cleaning and visualization
Data cleaning and visualizationData cleaning and visualization
Data cleaning and visualization
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
 
Queue
QueueQueue
Queue
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 

Similar to Stacks

Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
chandankumar364348
 
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptxSTACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
KALPANAC20
 

Similar to Stacks (20)

Stack and Queue.pptx
Stack and Queue.pptxStack and Queue.pptx
Stack and Queue.pptx
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
CD3291 2.5 stack.pptx
CD3291 2.5 stack.pptxCD3291 2.5 stack.pptx
CD3291 2.5 stack.pptx
 
Data structure.pdf
Data structure.pdfData structure.pdf
Data structure.pdf
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
 
DSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUEDSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUE
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
 
Unit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptxUnit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptx
 
Chapter 5-stack.pptx
Chapter 5-stack.pptxChapter 5-stack.pptx
Chapter 5-stack.pptx
 
Stacks
StacksStacks
Stacks
 
Stack operations using array
Stack operations using arrayStack operations using array
Stack operations using array
 
Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
 
Ds stack & queue
Ds   stack & queueDs   stack & queue
Ds stack & queue
 
Unit I.pptx
Unit I.pptxUnit I.pptx
Unit I.pptx
 
Circular queue
Circular queueCircular queue
Circular queue
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADT
 
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptxSTACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
 

More from Lovely Professional University

web_server_browser.ppt
web_server_browser.pptweb_server_browser.ppt
web_server_browser.ppt
Lovely Professional University
 
Web Server.pptx
Web Server.pptxWeb Server.pptx
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
Lovely Professional University
 
Programming Language.ppt
Programming Language.pptProgramming Language.ppt
Programming Language.ppt
Lovely Professional University
 
Information System.pptx
Information System.pptxInformation System.pptx
Information System.pptx
Lovely Professional University
 
Applications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptxApplications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptx
Lovely Professional University
 
Application of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptxApplication of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptx
Lovely Professional University
 
Requiring your own files.pptx
Requiring your own files.pptxRequiring your own files.pptx
Requiring your own files.pptx
Lovely Professional University
 

More from Lovely Professional University (20)

The HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageThe HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup language
 
Working with JSON
Working with JSONWorking with JSON
Working with JSON
 
Yargs Module
Yargs ModuleYargs Module
Yargs Module
 
NODEMON Module
NODEMON ModuleNODEMON Module
NODEMON Module
 
Getting Input from User
Getting Input from UserGetting Input from User
Getting Input from User
 
fs Module.pptx
fs Module.pptxfs Module.pptx
fs Module.pptx
 
Transaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptxTransaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptx
 
web_server_browser.ppt
web_server_browser.pptweb_server_browser.ppt
web_server_browser.ppt
 
Web Server.pptx
Web Server.pptxWeb Server.pptx
Web Server.pptx
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
 
Programming Language.ppt
Programming Language.pptProgramming Language.ppt
Programming Language.ppt
 
Information System.pptx
Information System.pptxInformation System.pptx
Information System.pptx
 
Applications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptxApplications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptx
 
Application of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptxApplication of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptx
 
Deploying your app.pptx
Deploying your app.pptxDeploying your app.pptx
Deploying your app.pptx
 
Setting up github and ssh keys.ppt
Setting up github and ssh keys.pptSetting up github and ssh keys.ppt
Setting up github and ssh keys.ppt
 
Adding a New Feature and Deploying.ppt
Adding a New Feature and Deploying.pptAdding a New Feature and Deploying.ppt
Adding a New Feature and Deploying.ppt
 
Requiring your own files.pptx
Requiring your own files.pptxRequiring your own files.pptx
Requiring your own files.pptx
 
Unit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptxUnit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptx
 
Yargs Module.pptx
Yargs Module.pptxYargs Module.pptx
Yargs Module.pptx
 

Recently uploaded

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 

Recently uploaded (20)

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 

Stacks

  • 1. Stacks • A stack is a container of objects that are inserted and removed according to the last-in first-out (LIFO) principle. In the pushdown stacks only two operations are allowed: push the item into the stack, and pop the item out of the stack.
  • 2. Important Hints • An array is a random access data structure, where each element can be accessed directly and in constant time. A typical illustration of random access is a book - each page of the book can be open independently of others. Random access is critical to many algorithms, for example binary search.
  • 3. In Programming, a special type of data structure in which items are removed in the reverse order from that in which they are added, so the most recently added item is the first one removed. This is also called last-in, first-out (LIFO).Adding an item to a stack is called pushing. Removing an item from a stack is called popping.
  • 4.
  • 5. Applications • The simplest application of a stack is to reverse a word. You push a given word to stack - letter by letter - and then pop letters from the stack. • Another application is an "undo" mechanism in text editors; this operation is accomplished by keeping all text changes in a stack. • Backtracking. This is a process when you need to access the most recent data element in a series of elements.
  • 6. Backtracking • Once you reach a dead end, you must backtrack. But backtrack to where? to the previous choice point. Therefore, at each choice point you store on a stack all possible choices. Then backtracking simply means popping a next choice from the stack.
  • 7. Language processing: • space for parameters and local variables is created internally using a stack. • compiler's syntax check for matching braces is implemented by using stack. • support for recursion
  • 8. Stack Operations using Array • Step 1: Include all the header files which are used in the program and define a constant 'SIZE' with specific value. • Step 2: Declare all the functions used in stack implementation. • Step 3: Create a one dimensional array with fixed size (int stack[SIZE])
  • 9. • Step 4: Define a integer variable 'top' and initialize with '-1'. (int top = -1) • Step 5: In main method display menu with list of operations and make suitable function calls to perform operation selected by the user on the stack.
  • 10. push(value) - Inserting value in the stack • In a stack, push() is a function used to insert an element into the stack. In a stack, the new element is always inserted at top position. Push function takes one integer value as parameter and inserts that value into the stack. We can use the following steps to push an element on to the stack...
  • 11. • Step 1: Check whether stack is FULL. (top == SIZE-1) • Step 2: If it is FULL, then display "Stack is FULL!!! Insertion is not possible!!!" and terminate the function. • Step 3: If it is NOT FULL, then increment top value by one (top++) and set stack[top] to value (stack[top] = value).
  • 12. pop() - Delete a value from the Stack • In a stack, pop() is a function used to delete an element from the stack. In a stack, the element is always deleted from top position. Pop function does not take any value as parameter. We can use the following steps to pop an element from the stack...
  • 13. • Step 1: Check whether stack is EMPTY. (top == -1) • Step 2: If it is EMPTY, then display "Stack is EMPTY!!! Deletion is not possible!!!" and terminate the function. • Step 3: If it is NOT EMPTY, then delete stack[top] and decrement top value by one (top--).
  • 14. display() - Displays the elements of a Stack • We can use the following steps to display the elements of a stack...
  • 15. • Step 1: Check whether stack is EMPTY. (top == -1) • Step 2: If it is EMPTY, then display "Stack is EMPTY!!!" and terminate the function. • Step 3: If it is NOT EMPTY, then define a variable 'i' and initialize with top. Display stack[i] value and decrement i value by one (i--). • Step 3: Repeat above step until i value becomes '0'.
  • 16. Program • #include<stdio.h> • #include<conio.h> • #define SIZE 10 • void push(int); • void pop(); • void display(); • int stack[SIZE], top = -1;
  • 17. • void push(int value) • { • if(top == SIZE-1) • printf("nStack is Full!!! Insertion is not possible!"); • else • { • top++; • stack[top] = value; • printf("nInsertion success!!!"); • } • }
  • 18. • void pop() • { • if(top == -1) • printf("nStack is Empty! Deletion is not possible!"); • else • { • printf("nDeleted : %d", stack[top]); • top--; • } • }
  • 19. • void display() • { • if(top == -1) • printf("nStack is Empty!!!"); • else • { • int i; • printf("nStack elements are:n"); • for(i=top; i>=0; i--) • printf("%dn",stack[i]); • } • }