#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node *next;
};
void traverseList(struct Node *head) {
struct Node *current = head;
int position = 0;
while (current != NULL) {
if (current == NULL) {
printf("NULL pointer detected at position %d (head pointer).\n", position);
return;
}
printf("Data at position %d: %d\n", position, current->data);
if (current->next == NULL) {
printf("NULL pointer detected at position %d (next pointer).\n", position + 1);
}
current = current->next;
position++;
}
}