#include #include struct node { int data; struct node *next; }; int main() { struct node *head = NULL, *newnode, *temp; // Allocate memory for a new node newnode = (struct node*)malloc(sizeof(struct node)); if (newnode == NULL) { printf("Memory allocation failed\n"); return 1; } // Input data for the new node printf("Enter Your Data:\n"); scanf("%d", &newnode->data); newnode->next = NULL; // Important to set the next pointer of the new node to NULL if (head == NULL) { head = temp = newnode; } else { temp->next = newnode; temp = newnode; } temp = head; while (temp != NULL) { struct node *next = temp->next; free(temp); temp = next; } return 0; }