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

What's hot

CalculateLoanPayments
CalculateLoanPaymentsCalculateLoanPayments
CalculateLoanPayments
William Rutherford
 
Functional Programming on Android: is it possible?
Functional Programming on Android: is it possible?Functional Programming on Android: is it possible?
Functional Programming on Android: is it possible?
Lucas Albuquerque
 
14. random numbertabletouchpad
14. random numbertabletouchpad14. random numbertabletouchpad
14. random numbertabletouchpad
Media4math
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
HarithaRanasinghe
 
งานย่อยที่ 7
งานย่อยที่ 7งานย่อยที่ 7
งานย่อยที่ 7
Little Aiiry
 
More than 100 keyboard shortcuts must read
More than 100 keyboard shortcuts must readMore than 100 keyboard shortcuts must read
More than 100 keyboard shortcuts must read
Rickson Saydoquen
 
microsoft windows keyboard shortcut
microsoft windows keyboard shortcutmicrosoft windows keyboard shortcut
microsoft windows keyboard shortcut
Sireesh K
 
Taller De Scilab
Taller De ScilabTaller De Scilab
Taller De Scilab
Andrés Renteria
 
Ejercicios Scilab Completo
Ejercicios Scilab CompletoEjercicios Scilab Completo
Ejercicios Scilab Completo
Ricardo Grandas
 
Trabajo Scilab
Trabajo ScilabTrabajo Scilab
Trabajo Scilab
alexistorres
 
New microsoft word document
New microsoft word documentNew microsoft word document
New microsoft word document
Abhishek Arya
 
Vs c# lecture10
Vs c# lecture10Vs c# lecture10
Vs c# lecture10
Saman M. Almufti
 
Microsoft a
Microsoft aMicrosoft a
Microsoft a
Ali Shah
 
6 new ES6 features
6 new ES6 features6 new ES6 features
6 new ES6 features
Kyle Dorman
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
Tanveer Malik
 
Keyboard shortcuts
Keyboard shortcutsKeyboard shortcuts
Keyboard shortcuts
aseener
 
Computer short cut key
Computer short cut keyComputer short cut key
Computer short cut key
JIN KHATRI
 
Keyboard shortcuts
Keyboard shortcutsKeyboard shortcuts
Keyboard shortcuts
Ashish Yadav
 
Programming a guide gui
Programming a guide guiProgramming a guide gui
Programming a guide gui
Mahmoud Hikmet
 
More than 100 keyboard shortcuts In Computer
More than 100 keyboard shortcuts In Computer More than 100 keyboard shortcuts In Computer
More than 100 keyboard shortcuts In Computer
TARUN VERMA
 

What's hot (20)

CalculateLoanPayments
CalculateLoanPaymentsCalculateLoanPayments
CalculateLoanPayments
 
Functional Programming on Android: is it possible?
Functional Programming on Android: is it possible?Functional Programming on Android: is it possible?
Functional Programming on Android: is it possible?
 
14. random numbertabletouchpad
14. random numbertabletouchpad14. random numbertabletouchpad
14. random numbertabletouchpad
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
งานย่อยที่ 7
งานย่อยที่ 7งานย่อยที่ 7
งานย่อยที่ 7
 
More than 100 keyboard shortcuts must read
More than 100 keyboard shortcuts must readMore than 100 keyboard shortcuts must read
More than 100 keyboard shortcuts must read
 
microsoft windows keyboard shortcut
microsoft windows keyboard shortcutmicrosoft windows keyboard shortcut
microsoft windows keyboard shortcut
 
Taller De Scilab
Taller De ScilabTaller De Scilab
Taller De Scilab
 
Ejercicios Scilab Completo
Ejercicios Scilab CompletoEjercicios Scilab Completo
Ejercicios Scilab Completo
 
Trabajo Scilab
Trabajo ScilabTrabajo Scilab
Trabajo Scilab
 
New microsoft word document
New microsoft word documentNew microsoft word document
New microsoft word document
 
Vs c# lecture10
Vs c# lecture10Vs c# lecture10
Vs c# lecture10
 
Microsoft a
Microsoft aMicrosoft a
Microsoft a
 
6 new ES6 features
6 new ES6 features6 new ES6 features
6 new ES6 features
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Keyboard shortcuts
Keyboard shortcutsKeyboard shortcuts
Keyboard shortcuts
 
Computer short cut key
Computer short cut keyComputer short cut key
Computer short cut key
 
Keyboard shortcuts
Keyboard shortcutsKeyboard shortcuts
Keyboard shortcuts
 
Programming a guide gui
Programming a guide guiProgramming a guide gui
Programming a guide gui
 
More than 100 keyboard shortcuts In Computer
More than 100 keyboard shortcuts In Computer More than 100 keyboard shortcuts In Computer
More than 100 keyboard shortcuts In Computer
 

Similar to Short Review of Stack

CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2
SIMONTHOMAS S
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
MeghaKulkarni27
 
Array menu
Array menuArray menu
Array menu
Sayantan Sur
 
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
Sheikh Monirul Hasan
 
STACK1.docx
STACK1.docxSTACK1.docx
STACK1.docx
CharanKeasavan
 
Data Structures : array operations in c program
Data Structures : array operations in c program Data Structures : array operations in c program
Data Structures : array operations in c program
Raghavendra Narayan
 
Practical_File_Of_Data_Structure.pdf
Practical_File_Of_Data_Structure.pdfPractical_File_Of_Data_Structure.pdf
Practical_File_Of_Data_Structure.pdf
VishwasChoclaty1
 
Single linked list
Single linked listSingle linked list
Single linked list
Sayantan Sur
 
Stack prgs
Stack prgsStack prgs
Stack prgs
Ssankett Negi
 
Final ds record
Final ds recordFinal ds record
Final ds record
Ganisius Ganish
 
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートIIopenFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
Atsushi Tadokoro
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
Sayantan Sur
 
#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx
ajoy21
 
Array imp of list
Array imp of listArray imp of list
Array imp of list
Elavarasi K
 
C programs Set 4
C programs Set 4C programs Set 4
C programs Set 4
Koshy Geoji
 
Array list
Array listArray list
Data Structure
Data StructureData Structure
Data Structure
Hitesh Mohapatra
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignment
sreekanth3dce
 
week-14x
week-14xweek-14x
Using C language to write an algorithm that accepts a list implement.pdf
Using C language to write an algorithm that accepts a list implement.pdfUsing C language to write an algorithm that accepts a list implement.pdf
Using C language to write an algorithm that accepts a list implement.pdf
smitaguptabootique
 

Similar to Short Review of Stack (20)

CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
Array menu
Array menuArray menu
Array menu
 
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
 
STACK1.docx
STACK1.docxSTACK1.docx
STACK1.docx
 
Data Structures : array operations in c program
Data Structures : array operations in c program Data Structures : array operations in c program
Data Structures : array operations in c program
 
Practical_File_Of_Data_Structure.pdf
Practical_File_Of_Data_Structure.pdfPractical_File_Of_Data_Structure.pdf
Practical_File_Of_Data_Structure.pdf
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Stack prgs
Stack prgsStack prgs
Stack prgs
 
Final ds record
Final ds recordFinal ds record
Final ds record
 
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートIIopenFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx
 
Array imp of list
Array imp of listArray imp of list
Array imp of list
 
C programs Set 4
C programs Set 4C programs Set 4
C programs Set 4
 
Array list
Array listArray list
Array list
 
Data Structure
Data StructureData Structure
Data Structure
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignment
 
week-14x
week-14xweek-14x
week-14x
 
Using C language to write an algorithm that accepts a list implement.pdf
Using C language to write an algorithm that accepts a list implement.pdfUsing C language to write an algorithm that accepts a list implement.pdf
Using C language to write an algorithm that accepts a list implement.pdf
 

More from Owali Shawon

Lecture 7
Lecture 7Lecture 7
Lecture 7
Owali Shawon
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
Owali Shawon
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
Owali Shawon
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
Owali Shawon
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
Owali Shawon
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
Owali Shawon
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
Owali Shawon
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Owali Shawon
 
ABOUT ME!
ABOUT ME! ABOUT ME!
ABOUT ME!
Owali Shawon
 
Electrical Circuit
Electrical CircuitElectrical Circuit
Electrical Circuit
Owali Shawon
 

More from Owali Shawon (10)

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

Recently uploaded

World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 

Recently uploaded (20)

World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 

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); } }