Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
12 views
2 pages
Dsu 17
Uploaded by
Nirav Parmar
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download
Save
Save DSU 17 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
12 views
2 pages
Dsu 17
Uploaded by
Nirav Parmar
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save DSU 17 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save DSU 17 For Later
You are on page 1
/ 2
Search
Fullscreen
Practical No.
17: * Write a 'C' Program to perform PUSH and POP Operations on
Stack using Linked List.
CODE :
#include <stdio.h> int poppedValue = temp->data;
#include <stdlib.h> *top = (*top)->next;
struct StackNode { free(temp);
int data; return poppedValue;
struct StackNode* next; }
}; }
struct StackNode* createNode(int value) void display(struct StackNode* top) {
{
if (isEmpty(top)) {
struct StackNode* newNode = (struct
StackNode*)malloc(sizeof(struct printf("Stack is empty.\n");
StackNode)); return;
newNode->data = value; }
newNode->next = NULL; printf("Stack elements: ");
return newNode; struct StackNode* temp = top;
} while (temp != NULL) {
int isEmpty(struct StackNode* top) { printf("%d ", temp->data);
return top == NULL; temp = temp->next;
} }
void push(struct StackNode** top, int printf("\n");
value) {
}
struct StackNode* newNode =
createNode(value); int main() {
newNode->next = *top; struct StackNode* top = NULL;
*top = newNode; int choice, value;
printf("%d pushed onto stack.\n", while (1) {
value);
printf("\nStack Operations Menu:\
} n");
int pop(struct StackNode** top) { printf("1. Push\n");
if (isEmpty(*top)) { printf("2. Pop\n");
printf("Stack Underflow! Cannot pop printf("3. Display Stack\n");
from an empty stack.\n");
printf("4. Exit\n");
return -1;
printf("Enter your choice (1-4): ");
} else {
scanf("%d", &choice);
struct StackNode* temp = *top;
switch (choice) { case 3:
case 1: display(top);
printf("Enter the value to push: break;
");
case 4:
scanf("%d", &value);
printf("Exiting program...\n");
push(&top, value);
return 0;
break;
default:
case 2:
printf("Invalid choice! Please
value = pop(&top); enter a valid choice (1-4).\n");
if (value != -1) { }
printf("Popped value: %d\n", }
value);
return 0;
}
}
break;
OUTPUT :
You might also like
Array&LL Implementation of Stack
PDF
No ratings yet
Array&LL Implementation of Stack
7 pages
Experiment 6
PDF
No ratings yet
Experiment 6
5 pages
DS Practical Solution
PDF
No ratings yet
DS Practical Solution
25 pages
Expp
PDF
No ratings yet
Expp
4 pages
Stacks Programs
PDF
No ratings yet
Stacks Programs
8 pages
Stack Operations
PDF
No ratings yet
Stack Operations
2 pages
DSP Lab
PDF
No ratings yet
DSP Lab
28 pages
Stack Linked List
PDF
No ratings yet
Stack Linked List
4 pages
EXPERIMENT 3 - Ds
PDF
No ratings yet
EXPERIMENT 3 - Ds
5 pages
Stack Using Linked List
PDF
No ratings yet
Stack Using Linked List
4 pages
Stack in C
PDF
No ratings yet
Stack in C
2 pages
Experiment 1
PDF
No ratings yet
Experiment 1
3 pages
Dsu Pr16 Main
PDF
No ratings yet
Dsu Pr16 Main
5 pages
Stack
PDF
No ratings yet
Stack
2 pages
Stack
PDF
No ratings yet
Stack
6 pages
Stackll
PDF
No ratings yet
Stackll
3 pages
C Linked List - Programming Exercises
PDF
No ratings yet
C Linked List - Programming Exercises
5 pages
Program 5 &6
PDF
No ratings yet
Program 5 &6
8 pages
DS Stack & Queue Using Linked List
PDF
No ratings yet
DS Stack & Queue Using Linked List
11 pages
Lab Program No. 3
PDF
No ratings yet
Lab Program No. 3
2 pages
3DSLABTASKS
PDF
No ratings yet
3DSLABTASKS
13 pages
Stack Using Array
PDF
No ratings yet
Stack Using Array
6 pages
Stack Using Linked List
PDF
No ratings yet
Stack Using Linked List
3 pages
Cs Project
PDF
No ratings yet
Cs Project
21 pages
Here Are The 15-WPS Office
PDF
No ratings yet
Here Are The 15-WPS Office
18 pages
Exp 4
PDF
No ratings yet
Exp 4
5 pages
Dsa Lab Questions
PDF
No ratings yet
Dsa Lab Questions
37 pages
Stack and Queue Using Linked List
PDF
No ratings yet
Stack and Queue Using Linked List
17 pages
Data Structures Lab
PDF
No ratings yet
Data Structures Lab
10 pages
DST External Program
PDF
No ratings yet
DST External Program
21 pages
16-Module-2 Linear Data Structures-10-Mar-2021Material I 10-Mar-2021 Stack Using LL
PDF
No ratings yet
16-Module-2 Linear Data Structures-10-Mar-2021Material I 10-Mar-2021 Stack Using LL
11 pages
Implementing Stack in C
PDF
No ratings yet
Implementing Stack in C
6 pages
Experiment 1
PDF
No ratings yet
Experiment 1
5 pages
DS Neha 8
PDF
No ratings yet
DS Neha 8
4 pages
Lab 5
PDF
No ratings yet
Lab 5
4 pages
C++ Program To Implement Queue Using Array
PDF
No ratings yet
C++ Program To Implement Queue Using Array
14 pages
Data ST
PDF
No ratings yet
Data ST
109 pages
Exercise 5
PDF
No ratings yet
Exercise 5
14 pages
Printouts (Ds Lab)
PDF
No ratings yet
Printouts (Ds Lab)
18 pages
Sodapdf
PDF
No ratings yet
Sodapdf
9 pages
S.I.E.S College of Arts, Science and Commerce, Sion (W), Mumbai - 400 002. S.Y.B.Sc (Computer Science) Certificate
PDF
No ratings yet
S.I.E.S College of Arts, Science and Commerce, Sion (W), Mumbai - 400 002. S.Y.B.Sc (Computer Science) Certificate
30 pages
Array Program
PDF
No ratings yet
Array Program
5 pages
Source Code
PDF
No ratings yet
Source Code
33 pages
DS Codes
PDF
No ratings yet
DS Codes
12 pages
Struct Int Struct: #Include #Include
PDF
No ratings yet
Struct Int Struct: #Include #Include
3 pages
Ds - All Codes
PDF
No ratings yet
Ds - All Codes
18 pages
Stack
PDF
No ratings yet
Stack
6 pages
Acp Part B Programs
PDF
No ratings yet
Acp Part B Programs
10 pages
Stack Implementation
PDF
No ratings yet
Stack Implementation
10 pages
FALLSEM2023-24 ITA3002 ETH VL2023240102705 2023-07-31 Reference-Material-I
PDF
No ratings yet
FALLSEM2023-24 ITA3002 ETH VL2023240102705 2023-07-31 Reference-Material-I
6 pages
Full Download The Future of HRD, Volume I: Innovation and Technology Mark Loon PDF
PDF
100% (2)
Full Download The Future of HRD, Volume I: Innovation and Technology Mark Loon PDF
76 pages
Program: Implement Stack ADT Using Array
PDF
No ratings yet
Program: Implement Stack ADT Using Array
18 pages
Experiment No.: 8: Implement A Stack Using A Single Linked List
PDF
No ratings yet
Experiment No.: 8: Implement A Stack Using A Single Linked List
11 pages
XVCXBV XVXXXXXXXV
PDF
No ratings yet
XVCXBV XVXXXXXXXV
22 pages
Program No. Aim:-To Check Whether The Entered String Is A Keyword or Not
PDF
No ratings yet
Program No. Aim:-To Check Whether The Entered String Is A Keyword or Not
11 pages
Art and Technology in Poland Ed. Agnieszka Jelewska
PDF
No ratings yet
Art and Technology in Poland Ed. Agnieszka Jelewska
258 pages
DS Lab
PDF
No ratings yet
DS Lab
46 pages
Visual Effects (VFX) Market 2034: Forecast & Analysis
PDF
No ratings yet
Visual Effects (VFX) Market 2034: Forecast & Analysis
10 pages
Dsa File
PDF
No ratings yet
Dsa File
43 pages
Linked Lists
PDF
No ratings yet
Linked Lists
11 pages
R June 6 Prakash Bari Health
PDF
No ratings yet
R June 6 Prakash Bari Health
6 pages
QMM Report Tata Steel
PDF
100% (1)
QMM Report Tata Steel
33 pages
Bell, SOME EXPERIMENTS IN DIAGNOSTIC TEACHING
PDF
No ratings yet
Bell, SOME EXPERIMENTS IN DIAGNOSTIC TEACHING
23 pages
Defence Standard 00-970 Part 1 Section 1: Issue 13 Date: 13 Jul 2015
PDF
No ratings yet
Defence Standard 00-970 Part 1 Section 1: Issue 13 Date: 13 Jul 2015
23 pages
Stackarray (Mayank Sharma)
PDF
No ratings yet
Stackarray (Mayank Sharma)
4 pages
Answers To The First General Quick TEST UTME
PDF
No ratings yet
Answers To The First General Quick TEST UTME
22 pages
Stack in C
PDF
No ratings yet
Stack in C
6 pages
Acyfar 3 Answer Key Q1andq2 T2ay2324
PDF
No ratings yet
Acyfar 3 Answer Key Q1andq2 T2ay2324
3 pages
Law of Property and Easement-NOTES
PDF
No ratings yet
Law of Property and Easement-NOTES
62 pages
Fourier Analysis-A Signal Processing Approach
PDF
No ratings yet
Fourier Analysis-A Signal Processing Approach
14 pages
Sanskrit PDF
PDF
No ratings yet
Sanskrit PDF
33 pages
SC9b - Homework
PDF
No ratings yet
SC9b - Homework
6 pages
FV - Pitch Deck - Company Name
PDF
No ratings yet
FV - Pitch Deck - Company Name
12 pages
The Role of Frontier Orbitals in Chemical Reactions
PDF
No ratings yet
The Role of Frontier Orbitals in Chemical Reactions
18 pages
Project - Up Land Law
PDF
No ratings yet
Project - Up Land Law
7 pages
What The Managers Really Do
PDF
No ratings yet
What The Managers Really Do
4 pages
Engineering The Mind
PDF
No ratings yet
Engineering The Mind
9 pages
CRM Section Two
PDF
No ratings yet
CRM Section Two
4 pages
Chapter 1 - Marketing in Today's Economy
PDF
No ratings yet
Chapter 1 - Marketing in Today's Economy
43 pages
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet
Lesson 1
PDF
No ratings yet
Lesson 1
4 pages
Chapter 2 Basic Physics of Semiconductors
PDF
No ratings yet
Chapter 2 Basic Physics of Semiconductors
42 pages
Withdrawn: Will Sell by Public Auction
PDF
No ratings yet
Withdrawn: Will Sell by Public Auction
1 page
Vocality Radio Over IP - Introduction
PDF
No ratings yet
Vocality Radio Over IP - Introduction
18 pages
Week 5 MODULE PURPOSIVE COMMUNICATION
PDF
No ratings yet
Week 5 MODULE PURPOSIVE COMMUNICATION
13 pages
Why The Hammered Bracelet Could Not Be Flown Over
PDF
No ratings yet
Why The Hammered Bracelet Could Not Be Flown Over
21 pages
Inspection Preparation For Ships
PDF
No ratings yet
Inspection Preparation For Ships
3 pages
Room Tariff: Special Rates On Continental Plan (CPAI)
PDF
No ratings yet
Room Tariff: Special Rates On Continental Plan (CPAI)
4 pages
Easy Love Spell
PDF
50% (2)
Easy Love Spell
2 pages
KYC Template Individual AnnexB1
PDF
No ratings yet
KYC Template Individual AnnexB1
1 page