Aim: Singly linklist
#include <stdio.h>
#include <stdlib.h>
// Define the node structure
struct Node {
int data;
struct Node* next;
};
// Function to insert a node at the beginning
void insertStart(struct Node** head, int data) {
struct Node* newNode = (struct Node*) malloc(sizeof(struct Node));
newNode->data = data;
newNode->next = *head;
*head = newNode;
printf("Inserted %d\n", newNode->data);
// Function to delete a node from the beginning
void deleteStart(struct Node** head) {
if (*head == NULL) {
printf("Impossible to delete from empty Singly Linked List\n");
return;
struct Node* temp = *head;
*head = (*head)->next;
printf("Deleted: %d\n", temp->data);
free(temp);
// Function to display the linked list
void display(struct Node* node) {
printf("\nLinked List: ");
while (node != NULL) {
printf("%d ", node->data);
node = node->next;
printf("\n");
int main() {
struct Node* head = NULL;
insertStart(&head, 10);
insertStart(&head, 20);
insertStart(&head, 30);
display(head);
deleteStart(&head);
display(head);
return 0;