Professional Documents
Culture Documents
BY:-
1. Kawade Dnyaneshwari Navanath .
2. Late Sandhya Gorakh .
3. Dahiwadkar Pranita Vijay.
Solapur.
CERTIFICATE
The project report entitled “Perform PUSH and POP operations on stack.”.
Submitted by:
Examiner Principal
( ) ( S.V Kulakarni)
Place: Solapur
Date:
Annexure II
Evolution Sheet for Micro Project
Academic Year: 2023-24 Name of Faculty: -Ms. Wadikar R.A
Course: - Computer Engineering Course Code: - CO3I
Subject: -Data Structure Using C Subject Code: -22317
rd
Semester:- 3 Scheme: - I
Title of
Perform PUSH and POP operations on stack.
Project: -
COs addressed by the Micro Project:
C01 Implement operations on stack and Queue using array.
Major Learning Outcomes achieved by students by doing the Project:
SUBMITTED BY:
2 Internet Youtube
1
3 textbook/manual DSU 22317 Data Structures Using C
5.0 Brief Introduction/Rationale
In C, a Stack is a linear data structure that obeys the LIFO (Last In First Out) approach to conduct a series of
basic operations like push, pop, peeks, and traverse. A Stack can be executed utilizing an Array or Linked
List.
A Stack is an abstract linear data structure operating as a group of elements that are inserted (push operation)
and withdrawn (pop operation) according to the Last in First Out (LIFO) approach. Insertion and deletion
occur on the same end (top) in a Stack. The top of the stack is returned utilizing the peek operation.
In C, the Stack data structure is an ordered, linear series of items. It is a LIFO (Last In First Out) data
structure, which means that we can insert or withdraw an item at the top of the stack only. It is a sequential
data type, unlike an array. In an array, we can access any of its elements utilizing indexing, but we can only
access the topmost element in a stack. The name "Stack" for this data structure comes from the metaphor of
a set of physical items stacked on top of each other. An example of this data structure would be a stack of
plates: We can only add a plate to the top of the stack and take a plate from the top of the stack. A stack of
coins or a stack of books can also be a real-life example of the stack data structure.
Introduction:
Stack is linear data structure where elements are inserted and deleted at one end that end is called as top of
the stack. As elements are inserted and deleted from top so it is called as last in first out (LIFO) structure.
Stack Terminology:
1)Stack:-It is linear data structure where elements are inserted and deleted at the same end.
2)Top:-The end where elements are inserted and deleted is called as top.
3)max:-It is the maximum size of stack.
4)overflow:-It is the condition which occurs when an element is added to the stack which is already
full.
5)underflow:- It is the condition which occurs when an element is deleted from the stack which is already
empty.
6)push():-The process of adding element to the stack is called as push.
7)pop():-The process of deleting element from the stack is called as pop.
When stack is not full we can add elements to the stack which is called as push, where top is incremented by
1.
When stack is not empty we can remove elements from the top of stack which is called as pop. After every
pop operation top is decremented by 1.
Operations
on stack:-
1)Is empty:-In this operation we are going to check wether stack is empty or not.
If(top==-1)
{
printf(“Stack is empty”);
}
2)Is full:-In this operation we are going to check whether satck is full or not.
if(top==max-1)
{
printf(“Stack is full”);
}
3)push:-In this operation we are going to add element to stack if stack is not full where after every push
operation top is incremented by 1.
Algorithm:-
1.Start
2.Check stack is full or not
if(top==max-1)
write “Stack is overflow”
3.else
Accept element from user.
++top;
St[top]=ele;
4.Stop.
4)pop:-In this operation we going to delete element from stack if stack is not empty.
Algorithm:-
1.Start
2.Check is stack is empty or not
if(top==-1)
{
Write “Stack Underflow”;
}
3.else
Decrement top by 1
--top;
4.Stop.
Applications of stack:-
1) Reversing string list
2) Polish Notations
3) Recursion
4) Tower of Hanoi
Execution
Stacks can be described using structures, pointers, arrays, or linked lists.
Program:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
# define max 10
int st[max],ele,top=-1,i;
void push()
if(top==max-1)
{
else
scanf(“%d”,&ele);
++top;
st[top]=ele;
void pop()
{
if(top==-1)
else
--top;
void display()
if(top==-1)
else
{
printf(“\n Stack\n”);
for(i=top;i>=0;i--)
{
printf(“%d”,st[i]);
voidmain()
{
int ch;
clrscr();
do
printf(“\n1)push\n2)pop\n3)display\n4)exit\n”);
scanf(“%d”,&ch);
switch(ch)
case 1: push();
break;
case 2: pop();
break;
case 3: display();
break;
case 4: exit(0);
break;
}while(ch!=4);
getch();
}
Output:-
Conclusion:-
Linear data structures maintain their data in an ordered fashion. Stacks works on a LIFO,
last-in first-out, ordering. The operations for a stack are push, pop, and isEmpty, isFull.
Reference:-
https://www.scribd.com/document/535215378/DSU-Unit-3-Stack
https://www.msbtemicroproject.tech/2022/11/DSU-22317-Data-Structures-Using-C-Microproject-
Computer-3rd-semester.html