Subscribe Us

Responsive Advertisement

Advertisement

Link List Creat and Traverse

 

Link List Creat and Traverse



#include<stdio.h>

#include<stdlib.h>

struct node

{

    int data;

    struct node *next;

};

int main()

{

    struct node *a=NULL,*b=NULL,*c=NULL;


    a=(struct node*)malloc(sizeof(struct node));

    b=(struct node*)malloc(sizeof(struct node));

    c=(struct node*)malloc(sizeof(struct node));

    a->data=10;

    b->data=20;

    c->data=30;

    a->next=b;

    b->next=c;

    c->next=NULL;

    while(a!=NULL)

    {


        printf("%d\n",a->data);

        a=a->next;

    }


    return 0;

}


Post a Comment

0 Comments