/* SY CSE 2024-25 Name: Akshay Rajendra
Sonwane Roll No: 65 Batch: S4
Program 13= Implementation of Stack using Linked list
#include <stdio.h>
#include <conio.h>
struct Node
int data;
struct Node *next;
};
struct Node *top=NULL;
void push(int);
void pop();
void display();
void main()
int choice, data;
clrscr();
printf("\n:: Stack using Linked List ::\n");
while(1)
printf("\n****** MENU ******\n");
printf("1. Push\n2. Pop\n3. Display\n4. Exit\n");
printf("Enter your choice: ");
scanf("%d",&choice);
switch(choice)
case 1: printf("Enter the data to PUSH: ");
scanf("%d", &data);
push(data);
break;
case 2: pop();
break;
case 3: display();
break;
case 4: exit(0);
default: printf("\nWrong choice !! Try again !!\n");
void push(int data)
struct Node *newNode;
newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->data = data;
if(top == NULL)
newNode->next = NULL;
else
newNode->next = top;
top = newNode;
printf("\nData pushed successfully..\n");
void pop()
if(top == NULL)
printf("\nStack is Empty!!!\n");
else
struct Node *temp = top;
printf("\nPOPed 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);
}
Output=