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
Black Book Abap
PDF
0% (2)
Black Book Abap
4 pages
Assignment - SQL Queries: Problem Statement
PDF
No ratings yet
Assignment - SQL Queries: Problem Statement
4 pages
Operations and Maintenance Plan RACI: R Responsible, A Accountable, C Consulted, I Informed
PDF
100% (2)
Operations and Maintenance Plan RACI: R Responsible, A Accountable, C Consulted, I Informed
11 pages
Inside The Javascript Engine: Created Created by Property Tags
PDF
100% (1)
Inside The Javascript Engine: Created Created by Property Tags
6 pages
Chapter 4 PPT
PDF
No ratings yet
Chapter 4 PPT
30 pages
Continuous Assessment Test 1&2: School of Computing and Informatics
PDF
100% (1)
Continuous Assessment Test 1&2: School of Computing and Informatics
2 pages
DUF User Guide
PDF
100% (1)
DUF User Guide
56 pages
Unit-I:: Introduction To Computers: Introduction To C
PDF
No ratings yet
Unit-I:: Introduction To Computers: Introduction To C
38 pages
It2305 Java Programming Question Bank
PDF
100% (3)
It2305 Java Programming Question Bank
3 pages
ACCS 7.1 Offer Definition V1 - 20 2020-12-02
PDF
No ratings yet
ACCS 7.1 Offer Definition V1 - 20 2020-12-02
63 pages
Stqa Unit 3 Notes
PDF
No ratings yet
Stqa Unit 3 Notes
22 pages
DevOps CI and Data Warehouse
PDF
No ratings yet
DevOps CI and Data Warehouse
30 pages
OpenACC Advanced Fixed
PDF
No ratings yet
OpenACC Advanced Fixed
53 pages
EMPAC™ For Teachers: Decode Technologies User Manual
PDF
No ratings yet
EMPAC™ For Teachers: Decode Technologies User Manual
26 pages
WT Report PDF
PDF
No ratings yet
WT Report PDF
38 pages
Ad - Java Lab Manual 2021-22
PDF
No ratings yet
Ad - Java Lab Manual 2021-22
79 pages
User Manual: Journal Article Latex Authoring Template
PDF
No ratings yet
User Manual: Journal Article Latex Authoring Template
14 pages
Managing Code in The Database
PDF
No ratings yet
Managing Code in The Database
84 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
Data Structures Lab
PDF
No ratings yet
Data Structures Lab
10 pages
Real Time Operating Systems
PDF
No ratings yet
Real Time Operating Systems
15 pages
XVCXBV XVXXXXXXXV
PDF
No ratings yet
XVCXBV XVXXXXXXXV
22 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
Fun With Menus: Navigation Using Jquery, Css3, and Html5: Examples For This Tutorial
PDF
No ratings yet
Fun With Menus: Navigation Using Jquery, Css3, and Html5: Examples For This Tutorial
10 pages
Microsoft Access
PDF
No ratings yet
Microsoft Access
11 pages
C++ Worksheet 6
PDF
No ratings yet
C++ Worksheet 6
6 pages
Screenshot 2023-10-25 at 12.16.51
PDF
No ratings yet
Screenshot 2023-10-25 at 12.16.51
31 pages
Lab 5
PDF
No ratings yet
Lab 5
4 pages
Stack and Queue Using Linked List
PDF
No ratings yet
Stack and Queue Using Linked List
17 pages
A Risk Based Story Prioritization Technique in An Agile Environment
PDF
No ratings yet
A Risk Based Story Prioritization Technique in An Agile Environment
10 pages
Data ST
PDF
No ratings yet
Data ST
109 pages
Enable Https On Ubuntu Web Server (20.04)
PDF
No ratings yet
Enable Https On Ubuntu Web Server (20.04)
8 pages
DS Stack & Queue Using Linked List
PDF
No ratings yet
DS Stack & Queue Using Linked List
11 pages
Struct Int Struct: #Include #Include
PDF
No ratings yet
Struct Int Struct: #Include #Include
3 pages
Acp Part B Programs
PDF
No ratings yet
Acp Part B Programs
10 pages
Exp 4
PDF
No ratings yet
Exp 4
5 pages
Dsa File
PDF
No ratings yet
Dsa File
43 pages
Stack Implementation
PDF
No ratings yet
Stack Implementation
10 pages
Array Program
PDF
No ratings yet
Array Program
5 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
DS Lab
PDF
No ratings yet
DS Lab
46 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
Linked Lists
PDF
No ratings yet
Linked Lists
11 pages
Array&LL Implementation of Stack
PDF
No ratings yet
Array&LL Implementation of Stack
7 pages
Program 5 &6
PDF
No ratings yet
Program 5 &6
8 pages
Stack in C
PDF
No ratings yet
Stack in C
6 pages
Change Control & SCM
PDF
No ratings yet
Change Control & SCM
19 pages
Source Code
PDF
No ratings yet
Source Code
33 pages
Dsa Lab Questions
PDF
No ratings yet
Dsa Lab Questions
37 pages
Stack
PDF
No ratings yet
Stack
6 pages
3DSLABTASKS
PDF
No ratings yet
3DSLABTASKS
13 pages
Lab Program No. 3
PDF
No ratings yet
Lab Program No. 3
2 pages
C Linked List - Programming Exercises
PDF
No ratings yet
C Linked List - Programming Exercises
5 pages
Program: Implement Stack ADT Using Array
PDF
No ratings yet
Program: Implement Stack ADT Using Array
18 pages
Dsu Pr16 Main
PDF
No ratings yet
Dsu Pr16 Main
5 pages
Implementing Stack in C
PDF
No ratings yet
Implementing Stack in C
6 pages
Wordpress Notes
PDF
No ratings yet
Wordpress Notes
4 pages
Stackll
PDF
No ratings yet
Stackll
3 pages
DS Codes
PDF
No ratings yet
DS Codes
12 pages
C++ Program To Implement Queue Using Array
PDF
No ratings yet
C++ Program To Implement Queue Using Array
14 pages
EXPERIMENT 3 - Ds
PDF
No ratings yet
EXPERIMENT 3 - Ds
5 pages
Python Notes
PDF
No ratings yet
Python Notes
110 pages
Ds - All Codes
PDF
No ratings yet
Ds - All Codes
18 pages
Stack
PDF
No ratings yet
Stack
2 pages
Stackarray (Mayank Sharma)
PDF
No ratings yet
Stackarray (Mayank Sharma)
4 pages
Experiment 1
PDF
No ratings yet
Experiment 1
3 pages
Stack Linked List
PDF
No ratings yet
Stack Linked List
4 pages
Stacks Programs
PDF
No ratings yet
Stacks Programs
8 pages
Stack in C
PDF
No ratings yet
Stack in C
2 pages
U18CSI1202-Problem Solving and Programming
PDF
No ratings yet
U18CSI1202-Problem Solving and Programming
3 pages
Exercise 5
PDF
No ratings yet
Exercise 5
14 pages
Milos Milic: Professional Profile Contact
PDF
No ratings yet
Milos Milic: Professional Profile Contact
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
Stack
PDF
No ratings yet
Stack
6 pages
DS Practical Solution
PDF
No ratings yet
DS Practical Solution
25 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
Expp
PDF
No ratings yet
Expp
4 pages
Experiment 6
PDF
No ratings yet
Experiment 6
5 pages
Here Are The 15-WPS Office
PDF
No ratings yet
Here Are The 15-WPS Office
18 pages
Stack Operations
PDF
No ratings yet
Stack Operations
2 pages
Sodapdf
PDF
No ratings yet
Sodapdf
9 pages
DSP Lab
PDF
No ratings yet
DSP Lab
28 pages
Experiment 1
PDF
No ratings yet
Experiment 1
5 pages
Stack Using Array
PDF
No ratings yet
Stack Using Array
6 pages
DS Neha 8
PDF
No ratings yet
DS Neha 8
4 pages
Stack Using Linked List
PDF
No ratings yet
Stack Using Linked List
4 pages
DST External Program
PDF
No ratings yet
DST External Program
21 pages
Printouts (Ds Lab)
PDF
No ratings yet
Printouts (Ds Lab)
18 pages
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet