Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
#include
struct Node { int data; struct Node *next; }; void printList(struct Node *head) { struct Node *current = head; while (current != NULL) { printf("%d -> ", current->data); current = current->next; } printf("NULL\n"); } int main() { struct Node a, b, c; a.data = 10; b.data = 20; c.data = 30; a.next = &b; b.next = &c; c.next = NULL; printList(&a); // Put a new node (15) between 10 and 20 struct Node d; d.data = 15; d.next = &b; // 15 points to 20 a.next = &d; // 10 points to 15 printList(&a); return 0; }
10 -> 20 -> 30 -> NULL
10 -> 15 -> 20 -> 30 -> NULL