Posts

Showing posts with the label Linked List | Data Structure With C

Linked List | Data Structure With C

Image
CSZONE Linked List | Data Structure With C #include <stdio.h> #include <stdlib.h> // A Single Linked List Node struct Node{ int data; struct Node* next; }; void Display_Linked_List(struct Node* list){ while(list!=NULL){ printf("%d->",list->data ); list = list->next; } // For Avoiding last -> while printing in last printf("\b\b"); } int main(){ //Creating Nodes struct Node* head = NULL; struct Node* second = NULL; struct Node* third = NULL; //Allocate three Nodes head = (struct Node*)malloc(sizeof(struct Node)); second = (struct Node*)malloc(sizeof(struct Node)); third = (struct Node*)malloc(sizeof(struct Node)); //Assigning The Values head->data = 1; head->next = second; second->data = 2; second->next = third; third->data = 3; third->next = NULL; Display_Linked_List(head); return 0; }