Stack Linked List
Stack Linked List
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
} *top = NULL;
void push(int);
void pop();
void display();
int main() {
while (1) {
scanf("%d", &choice);
switch (choice) {
case 1:
push(value);
break;
case 2:
pop();
break;
case 3:
display();
break;
exit(0);
default:
return 0;
if (newNode == NULL) {
return;
newNode->data = value;
newNode->next = top;
top = newNode;
printf("\nInsertion is successful!\n");
void pop() {
if (top == NULL)
printf("\nStack is Empty!\n");
else {
top = temp->next;
free(temp);
void display() {
if (top == NULL)
printf("\nStack is Empty!\n");
else {
printf("%d", temp->data);
temp = temp->next;
if (temp != NULL)
printf("\n");