DS File
DS File
#include <stdlib.h>
struct Node {
int data;
};
newNode->data = newData;
newNode->next = *head;
*head = newNode; }
temp = temp->next;
printf("NULL\n");}
int main() {
char choice;
scanf("%d", &n);
scanf("%d", &value);
insertAtBeginning(&head, value);
printList(head);
do {
scanf("%d", &newValue);
insertAtBeginning(&head, newValue);
printList(head);
printf("Do you want to insert another node at the beginning? (y/n): ");
printList(head);
return 0;}
OUTPUT:
Enter the number of elements in the list: 5
Enter element 1: 7
Enter element 2: 6
Enter element 3: 7
Enter element 4: 8
Enter element 5: 9
Updated Linked List: 5 -> 9 -> 8 -> 7 -> 6 -> 7 -> NULL