SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
Stack
-An implementation of Stack using
ARRAY in C.
The Main Module
#include<stdio.h>
#include<stdlib.h>
void push(), pop(), display();
int top=-1,stack[5];
int main()
{
int choice;
while(1)
{
printf("n----Stack Menu----n");
printf("1. Push.n");
printf("2. Pop.n");
printf("3. Display.n");
printf("4. Exit.n");
printf("Enter your choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1: push();
break;
case 2: pop();
break;
case 3: display();
break;
case 4: exit(0);
break;
default: printf("Invalid option.");
}
}
}
Insert An Element Into Stack
void push()
{
if(top<4)
{
int num;
printf("Enter an integer value: ");
scanf("%d",&num);
top++;
stack[top]=num;
}
else
{
printf("nStack Overflow.n");
}
display();
}
Delete An Element From Stack
void pop()
{
if(top>=0)
{
printf("Item popped is: %d",stack[top]);
top--;
}
else
{
printf("nStack Underflow.n");
}
display();
}
Display The Elements In Stack
void display()
{
int head=top;
if(head>=0)
{
printf("The items in the stack are: ");
while(head!=-1)
{
printf("n%d",stack[head]);
head--;
}
}
else
{
printf("nStack empty.n");
}
}
Presented By:-
Sayantan Sur
Thank You

More Related Content

What's hot (20)

PPT
Arrays
SARITHA REDDY
 
PPT
Queue data structure
anooppjoseph
 
PPTX
Priority queue in DSA
junnubabu
 
PPT
stack presentation
Shivalik college of engineering
 
PPTX
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
PDF
Stack
Zaid Shabbir
 
PPTX
Dynamic memory allocation in c
lavanya marichamy
 
PPTX
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
PPTX
Evaluation of postfix expression
Akhil Ahuja
 
PPTX
Circular queue
Lovely Professional University
 
PPTX
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
PPTX
Abstract Data Types
karthikeyanC40
 
PDF
Array data structure
maamir farooq
 
PPTX
Array ppt
Kaushal Mehta
 
PPTX
Tree in data structure
ghhgj jhgh
 
PPTX
linked list in data structure
shameen khan
 
PPSX
Stack
Seema Sharma
 
PPTX
Infix to postfix conversion
Then Murugeshwari
 
PPTX
Queue - Data Structure - Notes
Omprakash Chauhan
 
PPTX
Binary Tree Traversal
Dhrumil Panchal
 
Queue data structure
anooppjoseph
 
Priority queue in DSA
junnubabu
 
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
Dynamic memory allocation in c
lavanya marichamy
 
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
Evaluation of postfix expression
Akhil Ahuja
 
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
Abstract Data Types
karthikeyanC40
 
Array data structure
maamir farooq
 
Array ppt
Kaushal Mehta
 
Tree in data structure
ghhgj jhgh
 
linked list in data structure
shameen khan
 
Infix to postfix conversion
Then Murugeshwari
 
Queue - Data Structure - Notes
Omprakash Chauhan
 
Binary Tree Traversal
Dhrumil Panchal
 

Viewers also liked (11)

PPTX
Data structure Stack
Praveen Vishwakarma
 
PPSX
Data Structure (Stack)
Adam Mukharil Bachtiar
 
PPTX
Stack Data structure
B Liyanage Asanka
 
PPTX
Deque and its applications
Jsaddam Hussain
 
PPT
Stacks in algorithems & data structure
faran nawaz
 
PPT
Stack Data Structure & It's Application
Tech_MX
 
PDF
Applications of stack
eShikshak
 
PPTX
Stack data structure
Tech_MX
 
PPT
Stacks
Temperory mukesh
 
PPTX
Decision Support System(DSS)
Sayantan Sur
 
Data structure Stack
Praveen Vishwakarma
 
Data Structure (Stack)
Adam Mukharil Bachtiar
 
Stack Data structure
B Liyanage Asanka
 
Deque and its applications
Jsaddam Hussain
 
Stacks in algorithems & data structure
faran nawaz
 
Stack Data Structure & It's Application
Tech_MX
 
Applications of stack
eShikshak
 
Stack data structure
Tech_MX
 
Decision Support System(DSS)
Sayantan Sur
 
Ad

Similar to Stack using Array (20)

PPTX
Stack using Linked List
Sayantan Sur
 
PPTX
stack.pptx
MeghaKulkarni27
 
DOCX
DSA- Unit III- STACK AND QUEUE
swathirajstar
 
PPTX
CS8391-Data Structures Unit 2
SIMONTHOMAS S
 
PPTX
DS- Stack ADT
MythiliMurugan3
 
PPT
StackArray stack3
Rajendran
 
PPTX
Stack of Data structure
Sheikh Monirul Hasan
 
PPTX
Stacks in Data Structure
Lovely Professional University
 
DOCX
Stack operations using array
aluavi
 
PPTX
STACKS implimentarions AND stack applications .pptx
Dr. Amna Mohamed
 
PDF
04 stacks
Rajan Gautam
 
PDF
Chapter 4 stack
jadhav_priti
 
PPTX
STACK.pptx
rupam100
 
DOCX
#C programming Question 35Implement the functions required for the.docx
ajoy21
 
PPTX
Stack and Queue.pptx university exam preparation
RAtna29
 
PPTX
6 - STACKS in Data Structure and Algorithm.pptx
RahulRaj493025
 
PPTX
Stack presentation
Arun Shinde
 
DOCX
Ds
Acad
 
Stack using Linked List
Sayantan Sur
 
stack.pptx
MeghaKulkarni27
 
DSA- Unit III- STACK AND QUEUE
swathirajstar
 
CS8391-Data Structures Unit 2
SIMONTHOMAS S
 
DS- Stack ADT
MythiliMurugan3
 
StackArray stack3
Rajendran
 
Stack of Data structure
Sheikh Monirul Hasan
 
Stacks in Data Structure
Lovely Professional University
 
Stack operations using array
aluavi
 
STACKS implimentarions AND stack applications .pptx
Dr. Amna Mohamed
 
04 stacks
Rajan Gautam
 
Chapter 4 stack
jadhav_priti
 
STACK.pptx
rupam100
 
#C programming Question 35Implement the functions required for the.docx
ajoy21
 
Stack and Queue.pptx university exam preparation
RAtna29
 
6 - STACKS in Data Structure and Algorithm.pptx
RahulRaj493025
 
Stack presentation
Arun Shinde
 
Ds
Acad
 
Ad

More from Sayantan Sur (10)

PPTX
Image Encryption and Compression
Sayantan Sur
 
PPTX
Array menu
Sayantan Sur
 
PPTX
Double linked list
Sayantan Sur
 
PPTX
Single linked list
Sayantan Sur
 
PPTX
Circular linked list
Sayantan Sur
 
PPT
Network Security
Sayantan Sur
 
PPT
Visual Studio IDE
Sayantan Sur
 
PPTX
Ethical Hacking
Sayantan Sur
 
PPT
Phising
Sayantan Sur
 
PPT
International Terrorism
Sayantan Sur
 
Image Encryption and Compression
Sayantan Sur
 
Array menu
Sayantan Sur
 
Double linked list
Sayantan Sur
 
Single linked list
Sayantan Sur
 
Circular linked list
Sayantan Sur
 
Network Security
Sayantan Sur
 
Visual Studio IDE
Sayantan Sur
 
Ethical Hacking
Sayantan Sur
 
Phising
Sayantan Sur
 
International Terrorism
Sayantan Sur
 

Recently uploaded (20)

PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PPT
Indian Contract Act 1872, Business Law #MBA #BBA #BCOM
priyasinghy107
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Controller Request and Response in Odoo18
Celine George
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
Indian Contract Act 1872, Business Law #MBA #BBA #BCOM
priyasinghy107
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Difference between write and update in odoo 18
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Introduction to Indian Writing in English
Trushali Dodiya
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 

Stack using Array

  • 1. Stack -An implementation of Stack using ARRAY in C.
  • 2. The Main Module #include<stdio.h> #include<stdlib.h> void push(), pop(), display(); int top=-1,stack[5]; int main() { int choice; while(1) { printf("n----Stack Menu----n"); printf("1. Push.n"); printf("2. Pop.n"); printf("3. Display.n"); printf("4. Exit.n"); printf("Enter your choice: "); scanf("%d",&choice); switch(choice) { case 1: push(); break; case 2: pop(); break; case 3: display(); break; case 4: exit(0); break; default: printf("Invalid option."); } } }
  • 3. Insert An Element Into Stack void push() { if(top<4) { int num; printf("Enter an integer value: "); scanf("%d",&num); top++; stack[top]=num; } else { printf("nStack Overflow.n"); } display(); }
  • 4. Delete An Element From Stack void pop() { if(top>=0) { printf("Item popped is: %d",stack[top]); top--; } else { printf("nStack Underflow.n"); } display(); }
  • 5. Display The Elements In Stack void display() { int head=top; if(head>=0) { printf("The items in the stack are: "); while(head!=-1) { printf("n%d",stack[head]); head--; } } else { printf("nStack empty.n"); } }