SlideShare a Scribd company logo
STACK?
Useful data
structure in
programming
1 Pile of plates
kept on top
of each other
2
• Put a new plate on top
Last In First Out
• Remove the top plate
Push
Pop
IsEmpty
IsFull
Peek
void main()
{
int choice, value;
printf("n:: Stack using Linked List ::n");
while(1)
{
printf("n****** MENU ******n");
printf("1. Pushn2. Popn3. Displayn4. Exitn");
printf("Enter your choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter the value to be insert: ");
scanf("%d", &value);
push(value);
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf("nWrong selection!!! Please try again!!!n");
}
}
}
Stack in Code
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct Node
{
int data;
struct Node *next;
}*top = NULL;
void push(int);
void pop();
void display();
void push(int value)
{
struct Node *newNode;
newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->data = value;
if(top == NULL)
newNode->next = NULL;
else
newNode->next = top;
top = newNode;
printf("nInsertion is Success!!!n");
}
void pop()
{
if(top == NULL)
printf("nStack is Empty!!!n");
else{
struct Node *temp = top;
printf("nDeleted element: %d", temp->data);
top = temp->next;
free(temp);
}
}
void display()
{
if(top == NULL)
printf("nStack is Empty!!!n");
else{
struct Node *temp = top;
while(temp->next != NULL){
printf("%d--->",temp->data);
temp = temp -> next;
}
printf("%d--->NULL",temp->data);
}
}
Thank You

More Related Content

PDF
Stack Data Structure
PPTX
DS- Stack ADT
PPT
StackArray stack3
PPTX
Stack using Linked List
PPTX
Stack using Array
PPTX
Grokking TechTalk #16: Maybe functor in javascript
DOCX
การหาปริมาตรของปร ซึม
Stack Data Structure
DS- Stack ADT
StackArray stack3
Stack using Linked List
Stack using Array
Grokking TechTalk #16: Maybe functor in javascript
การหาปริมาตรของปร ซึม

What's hot (20)

PDF
CalculateLoanPayments
PDF
Functional Programming on Android: is it possible?
PDF
14. random numbertabletouchpad
PPTX
Session07 recursion
DOCX
งานย่อยที่ 7
DOCX
More than 100 keyboard shortcuts must read
PPTX
microsoft windows keyboard shortcut
DOCX
Taller De Scilab
DOCX
Ejercicios Scilab Completo
DOCX
Trabajo Scilab
DOCX
New microsoft word document
PPTX
Vs c# lecture10
DOC
Microsoft a
PDF
6 new ES6 features
PDF
Lecture 6
DOCX
Keyboard shortcuts
TXT
Computer short cut key
DOCX
Keyboard shortcuts
PPTX
Programming a guide gui
PDF
More than 100 keyboard shortcuts In Computer
CalculateLoanPayments
Functional Programming on Android: is it possible?
14. random numbertabletouchpad
Session07 recursion
งานย่อยที่ 7
More than 100 keyboard shortcuts must read
microsoft windows keyboard shortcut
Taller De Scilab
Ejercicios Scilab Completo
Trabajo Scilab
New microsoft word document
Vs c# lecture10
Microsoft a
6 new ES6 features
Lecture 6
Keyboard shortcuts
Computer short cut key
Keyboard shortcuts
Programming a guide gui
More than 100 keyboard shortcuts In Computer
Ad

Similar to Short Review of Stack (20)

PPTX
CS8391-Data Structures Unit 2
PDF
Chapter 4 stack
DOCX
DSA- Unit III- STACK AND QUEUE
PPT
MO 2020 DS Stacks 1 AB.ppt
PPTX
STACKS implimentarions AND stack applications .pptx
PPTX
Stack of Data structure
PDF
PPT
Unit ii(dsc++)
PDF
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
PPT
DS Unit 2.ppt
PPTX
Ll.pptx
PPTX
linked list.pptx
PPTX
DS-3asdfghjklxmmcnaefiuhavbifuhablc.pptx
PPTX
Data Structure.pptx
PDF
04 stacks
PPTX
Stack in Data Structoiqowerdjsakdffuh0ownfiuh .pptx
PPTX
ELEMENTARY DATASTRUCTURES
PPTX
Revisiting a data structures in detail with linked list stack and queue
PPT
Singly Circular Linked List – Last node points to the first node.
PPT
Wk11-linkedlist.ppt linked list complete iit
CS8391-Data Structures Unit 2
Chapter 4 stack
DSA- Unit III- STACK AND QUEUE
MO 2020 DS Stacks 1 AB.ppt
STACKS implimentarions AND stack applications .pptx
Stack of Data structure
Unit ii(dsc++)
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
DS Unit 2.ppt
Ll.pptx
linked list.pptx
DS-3asdfghjklxmmcnaefiuhavbifuhablc.pptx
Data Structure.pptx
04 stacks
Stack in Data Structoiqowerdjsakdffuh0ownfiuh .pptx
ELEMENTARY DATASTRUCTURES
Revisiting a data structures in detail with linked list stack and queue
Singly Circular Linked List – Last node points to the first node.
Wk11-linkedlist.ppt linked list complete iit
Ad

More from Owali Shawon (10)

PPTX
Lecture 7
PPTX
Lecture 8
PPTX
Lecture 6
PPTX
Lecture 2
PPTX
Lecture 5
PPTX
Lecture 4
PPTX
Lecture 3
PPTX
Lecture 1
PPTX
ABOUT ME!
PPTX
Electrical Circuit
Lecture 7
Lecture 8
Lecture 6
Lecture 2
Lecture 5
Lecture 4
Lecture 3
Lecture 1
ABOUT ME!
Electrical Circuit

Recently uploaded (20)

PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
01-Introduction-to-Information-Management.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Classroom Observation Tools for Teachers
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Presentation on HIE in infants and its manifestations
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Computing-Curriculum for Schools in Ghana
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O7-L3 Supply Chain Operations - ICLT Program
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
VCE English Exam - Section C Student Revision Booklet
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
01-Introduction-to-Information-Management.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Supply Chain Operations Speaking Notes -ICLT Program
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Classroom Observation Tools for Teachers
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Presentation on HIE in infants and its manifestations
Microbial disease of the cardiovascular and lymphatic systems
Computing-Curriculum for Schools in Ghana
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx

Short Review of Stack

  • 1. STACK? Useful data structure in programming 1 Pile of plates kept on top of each other 2
  • 2. • Put a new plate on top Last In First Out • Remove the top plate
  • 4. void main() { int choice, value; printf("n:: Stack using Linked List ::n"); while(1) { printf("n****** MENU ******n"); printf("1. Pushn2. Popn3. Displayn4. Exitn"); printf("Enter your choice: "); scanf("%d",&choice); switch(choice) { case 1: printf("Enter the value to be insert: "); scanf("%d", &value); push(value); break; case 2: pop(); break; case 3: display(); break; case 4: exit(0); default: printf("nWrong selection!!! Please try again!!!n"); } } } Stack in Code #include<stdio.h> #include<stdlib.h> #include<conio.h> struct Node { int data; struct Node *next; }*top = NULL; void push(int); void pop(); void display();
  • 5. void push(int value) { struct Node *newNode; newNode = (struct Node*)malloc(sizeof(struct Node)); newNode->data = value; if(top == NULL) newNode->next = NULL; else newNode->next = top; top = newNode; printf("nInsertion is Success!!!n"); }
  • 6. void pop() { if(top == NULL) printf("nStack is Empty!!!n"); else{ struct Node *temp = top; printf("nDeleted element: %d", temp->data); top = temp->next; free(temp); } }
  • 7. void display() { if(top == NULL) printf("nStack is Empty!!!n"); else{ struct Node *temp = top; while(temp->next != NULL){ printf("%d--->",temp->data); temp = temp -> next; } printf("%d--->NULL",temp->data); } }