LAb2 / Exercise 1- Linked List

PHOTO EMBED

Wed Oct 25 2023 18:22:53 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #java

//CREATİON OF LİNKLİST

#include <stdio.h>
#include <stdlib.h>

typedef struct 
{
    int data;
    struct Node*next;
    
} Node;

int main() {
    
    Node* n1;
    Node* n2;
    Node* n3;
    
    n1 = (Node*)(malloc(sizeof(Node)));
    n2 = (Node*)(malloc(sizeof(Node)));
    n3 = (Node*)(malloc(sizeof(Node)));
    
    
    n1 -> data = 10;
    n2 -> data = 20;
    n3 -> data = 30;
    
    
    n1 -> next = n2;
    n2 -> next = n3;
    n3 -> next = NULL;
    
    
    Node* temp = n1;
    
    while(temp != NULL)
    {
        printf("\nData: %d , next Adress: %d", temp -> data, temp -> next);
        temp = temp -> next;
    }

    return 0;
}
content_copyCOPY