C program to create a linked list and display the elements in the list.

Data structures using C,
C program to create a linked list and display the elements in the list. Linked list is a data structure in which the objects are arranged in a linear order. Linked List contains group of nodes, in which each node contains two fields, one is data field and another one is the reference field which contains the address of next node. Read more about C Programming Language .

* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* Happy Coding

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

void main()
struct node
int num;
struct node *ptr;

typedef struct node NODE;

NODE *head, *first, *temp=0;
int count = 0;
int choice = 1;
first = 0;

head =(NODE*) malloc(sizeof(NODE));
printf("Enter the data itemn");
scanf("%d", &head-> num);

if(first != 0)
temp->ptr = head;
temp = head;
first = temp = head;
printf("Do you want to continue(Type 0 or 1)?n");
scanf("%d", &choice);

} /* End of while */

temp->ptr = 0;
temp = first; /* reset temp to the beginning*/
printf("nstatus of the linked list isn");

printf("%d=>", temp->num);
temp = temp -> ptr;
printf("No. of nodes in the list = %dn", count);
} /* End of main*/
Read more Similar C Programs
Data Structures

Learn C Programming

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

Leave a Reply