implement stack using link list in c

#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0

struct node
{
    int data;
    struct node *next;
};
typedef struct node node;

node *top;

void initialize()
{
    top = NULL;
}

void push(int value)
{
    node *tmp;
    tmp = malloc(sizeof(node));
    tmp -> data = value;
    tmp -> next = top;
    top = tmp;
}

int pop()
{
    node *tmp;
    int n;
    tmp = top;
    n = tmp->data;
    top = top->next;
    free(tmp);
    return n;
}

int Top()
{
    return top->data;
}

int isempty()
{
    return top==NULL;
}

void display(node *head)
{
    if(head == NULL)
    {
        printf("NULL\n");
    }
    else
    {
        printf("%d\n", head -> data);
        display(head->next);
    }
}

int main()
{
    initialize();
    push(10);
    push(20);
    push(30);
    printf("The top is %d\n",Top());
    pop();
    printf("The top after pop is %d\n",Top());
    display(top);
    return 0;
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
c code to implement stack using linked list stack display function in c in lined list program to implement a stack using Linked List in c Stack linked list implementation c create a stack using linked list in c stack linked list implementation in c stack using linked list program in c stack c linked list stack with linked list program in c stack with linked list code in c operations to implement in stack using linked list in c linked list example in C stack overflow simple stack operations c with linked list stack with linked list c stack operations using linkedlist in c linked list stack in c creating a stack in c with linked list stack c program using linked list stack implementation using linked list in c linked list implementation of stack in c sample code for stack implementation using linked list program to implement stack operations using linked list. stack implementation in c using linked list linked list stack implementation is empty linked list implementation of stack using c implement a stack using linked list in c wap for linked list implement stack pop and push in c wap for linked list implement stack pop and push sStack using LL implement stack with linked list stack implementation using linked list stack implementation using linked list and with out switch case statement in c implement stack using linkedlist pushing an element in linked list w.a.p for implementation of stack using arrays and link list showingh push,pop and display operation linked list implementation of stack stack using linked list in c stacks using singly linked list stack creation in c code using linked list creation of stack using linked list in c algorithm stack adt using linked list in c implementation of linked listwith stack Write a program to implement ation of list as stack pop function for stack with linked list stack with linked list stack as linked list c program to implement stack using circular linked list stack using linked list in c program stack using singly linked list stack using sll stacks using linked list c stack implement using linked list stack with linked list in c Stack implemetation using linked list menu driven program for stack in c using linked list stack in c using linked list stack using linked list string in c stack linked list implementation stack ked list implementation stack linked list in c stack and link implementing stack using linked list stack implementation using link in c stack implementation using link which functin of linked list is used in push and pop stack using linked list without pointer in c staqck using linked list using single pointer Linked List implementation of Stack and Queue. in c stack using linked list C linked stack in c Write a C program to implement stack using Linked list representation. When we implement stack by using linked list then when we implement stack by linked list Write a program to implement stack using linked list. implement a stack using linked list stack as linked list c implementation of stack using linked list when we implement stack using linked list then insertion of node is done when we implememt stck by using liked list stack and queue using linked list program in c stack program in c using linked list linked list stack program in c how to implement stack with linked list c program to implement stack using singly linked list 2.Write A program to implement Stack using Linked List in c linked list stack stack using singly linked list c stack using ll in c c program to implement stack adt using a singly linked list write a c program implement stack adt using singly linked list write a c program/ algorithm to implement stack adt using singly linked list. perform following operations: implementation of stack using linked list in c singly linked list as stack peek in stack uing linked list stack using linkedlist in c implementation a stack using singly linked list complexity popping from a stack implementation as a singly linked list implementing all the Stack Operations using Linked List implementing a stack using a linked list in c stack using linkedlist Write a code for stack using linked list stacks using linked list in c implementing a linked list using stack stack using linked list implement stack using ll implement stack using linked list Write a function to pop an element and push an element into a stack using SLL implement stack using link list in c
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source