Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // LinkedListc.cpp : Defines the entry point for the console application.
- //https://www.opentechguides.com/how-to/article/c/141/linkedlist-add-del-print-count.html
- //https://www.geeksforgeeks.org/linked-list-set-1-introduction/
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct node
- {
- int data;
- struct node * next;
- }Node;
- Node * add(int, Node *);
- Node * remove(int , Node *);
- Node * display(int, Node *);
- Node * add(int num, Node *head)
- {
- Node * newnode;
- newnode = (Node *)malloc(sizeof(Node));
- newnode->data = num;
- newnode->next = head;
- head = newnode;
- return head;
- }
- Node * remove(int num, Node *head)
- {
- Node * current = head;
- Node * previous;
- if (current)
- }
- {Node * display(int num, Node *head)
- }
- int main()
- {
- struct node *head = NULL;
- struct node *current = NULL;
- struct node *previous = NULL;
- int num;
- int choice;
- if (head == NULL)
- {
- return 1;
- }
- while (1)
- {
- printf("1. Add");
- printf("2. Remove");
- printf("3. Display");
- printf("4. Exit");
- printf("Choose an option from 1 - 4");
- scanf("%d", &choice);
- switch (choice)
- {
- case 1:
- printf("Enter a value to enter the list");
- scanf("%d", &num);
- printf("Assign a priority to the value");
- printf("The element has been added to the list");
- getch();
- break;
- case 2:
- printf("Enter a value to enter the list");
- scanf("%d", &num);
- printf("The element has been removed from the list");
- getch();
- break;
- case 3:
- printf("Here is the list of values and elements");
- getch();
- break;
- case 4:
- exit(0);
- break;
- case 5:
- printf("Invalid");
- getch();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement