Posts

Write a c program to demonstrate pre-processor directives conditional Compilation

 #include <stdio.h> // Define DEBUG to enable debug-specific code #define DEBUG // Define VERSION to switch between different versions of the code #define VERSION 2 int main() {     printf("Conditional Compilation Demonstration\n"); #ifdef DEBUG     printf("Debug mode is enabled.\n"); #endif #if VERSION == 1     printf("This is version 1 of the program.\n"); #elif VERSION == 2     printf("This is version 2 of the program.\n"); #else     printf("Unknown version.\n"); #endif #ifndef DEBUG     printf("Debug mode is not enabled.\n"); #endif     return 0; }

Write a c program to Create a Circular DoubleLinked list and perform Following Operations A. Insertion After a particular node B. Insertion Before a particular node C. Search a particular node D. Return a particular node E. Deletion before a particular node F. Delete a particular node

 #include <stdio.h> #include <stdlib.h> // Define the structure for a node in the circular doubly linked list struct Node {     int data;     struct Node* next;     struct Node* prev; }; // Function to create a new node with given data struct Node* createNode(int data) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = data;     newNode->next = newNode;     newNode->prev = newNode;     return newNode; } // Function to insert a node at the end of the circular doubly linked list void insertAtEnd(struct Node** head, int data) {     struct Node* newNode = createNode(data);     if (*head == NULL) {         *head = newNode;     } else {         struct Node* last = (*head)->prev;         newNode->next = *head;         (*head)->prev ...

Write a c program to Create a Circular single Linked list and perform Following Operations A. Insertion After a particular node B. Insertion Before a particular node C. Search a particular node D. Return a particular node E. Deletion before a particular node F. Delete a particular node

 #include <stdio.h> #include <stdlib.h> // Define the structure for a node in the circular linked list struct Node {     int data;     struct Node* next; }; // Function to create a new node with given data struct Node* createNode(int data) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = data;     newNode->next = NULL;     return newNode; } // Function to insert a node at the beginning of the circular linked list void insertAtBeginning(struct Node** head, int data) {     struct Node* newNode = createNode(data);     if (*head == NULL) {         newNode->next = newNode;         *head = newNode;     } else {         struct Node* temp = *head;         while (temp->next != *head) {             temp = temp->next;   ...

Write a c program to Create a Circular Linked list and perform Following Operations A. Insertion At Beginning B. Insertion At End C. Insertion After a particular node Insertion Before a particular node E. Insertion at specific position F. Search a particular node G. Return a particular node H. Deletion at the beginning I. Deletion at the end J. Deletion after a particular node K. Deletion before a particular node L. Delete a particular node M. Deletion at a specific position

#include <stdio.h> #include <stdlib.h> // Define the structure for a node in the linked list struct Node {     int data;     struct Node* next; }; // Function to create a new node with given data struct Node* createNode(int data) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = data;     newNode->next = NULL;     return newNode; } // Function to insert a node at the beginning of the linked list void insertAtBeginning(struct Node** head, int data) {     struct Node* newNode = createNode(data);     newNode->next = *head;     *head = newNode; } // Function to insert a node at the end of the linked list void insertAtEnd(struct Node** head, int data) {     struct Node* newNode = createNode(data);     if (*head == NULL) {         *head = newNode;         return;     } ...

Write a c program to check whether the created linked list is palindrome or not

 #include <stdio.h> #include <stdlib.h> #include <stdbool.h> // Define the structure for a node in the linked list struct Node {     int data;     struct Node* next; }; // Function to create a new node with given data struct Node* createNode(int data) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = data;     newNode->next = NULL;     return newNode; } // Function to insert a node at the end of the linked list void insertAtEnd(struct Node** head, int data) {     struct Node* newNode = createNode(data);     if (*head == NULL) {         *head = newNode;         return;     }     struct Node* temp = *head;     while (temp->next != NULL) {         temp = temp->next;     }     temp->next = newNode; } // Function to print the ...

Write a program to Reverse a singly Linked list

 #include <stdio.h> #include <stdlib.h> // Define the structure for a node in the linked list struct Node {     int data;     struct Node* next; }; // Function to create a new node with given data struct Node* createNode(int data) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = data;     newNode->next = NULL;     return newNode; } // Function to insert a node at the end of the linked list void insertAtEnd(struct Node** head, int data) {     struct Node* newNode = createNode(data);     if (*head == NULL) {         *head = newNode;         return;     }     struct Node* temp = *head;     while (temp->next != NULL) {         temp = temp->next;     }     temp->next = newNode; } // Function to print the linked list void printList(...

Write a c program to Create a single Linked list and perform Following Operations A. Insertion At Beginning B. Insertion At End C. Insertion After a particular node D. Insertion Before a particular node E. Insertion at specific position F. Search a particular node G. Return a particular node H. Deletion at the beginning I. Deletion at the end J. Deletion after a particular node K. Deletion before a particular node L. Delete a particular node M. Deletion at a specific position

 #include <stdio.h> #include <stdlib.h> // Define the structure for a node in the linked list struct Node {     int data;     struct Node* next; }; // Function to create a new node with given data struct Node* createNode(int data) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = data;     newNode->next = NULL;     return newNode; } // Function to insert a node at the beginning of the linked list void insertAtBeginning(struct Node** head, int data) {     struct Node* newNode = createNode(data);     newNode->next = *head;     *head = newNode; } // Function to insert a node at the end of the linked list void insertAtEnd(struct Node** head, int data) {     struct Node* newNode = createNode(data);     if (*head == NULL) {         *head = newNode;         return;     ...