Wa0047.
Wa0047.
1. Structure of a Node
Each node in a singly linked list is
composed of:
struct Node {
int data; // Stores the data
struct Node* next; // Pointer to the
next node
};
1. Creating a Node:
A function is used to allocate memory
dynamically for a new node using
malloc() and initialize its data and next
pointer.
PROGRAM:-
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
prev->next = temp->next;
free(temp);
}
int main() {
struct Node* head = NULL;
insertAtEnd(&head, 40);
insertAtEnd(&head, 60);
insertAtEnd(&head, 80);
insertAtHead(&head, 5);
printf("Linked List: ");
printList(head);
return 0;
}
OUTPUT:-