×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Sort the List Elements - Link List in C Insert a node into a Circular Singly linked list
Create a Circular Singly linked list - Link list - C Language
1491    Arnab De    22/09/2019

Create a Circular Singly linked list

We have already create linear singly linked list in my previous post. Now I going to create a circular singly linked list. Now the question is that why it is circular or what are difference between linear linked list and circular linked list. In linear linked list last node is connected to the NULL pointer but in case of circular linked list last node of the list is connected to the first node of the list.

circular singly linked list
softetechnologies

Algorithms

Step 1 : Create a new node.

Step 2 : Read the data for the node.

Step 3 : Set the data in the data part of the node.

Step 4 : Set the reference part of the node to itself.

Step 5 : Return the created node reference to the main program.

softetechnologies

Program

#include <stdio.h>
#include <conio.h>
struct linklist
{
	int i;
	struct linklist *next;
};
typedef struct linklist node;

//prototype declaration
node *create(node *);
node *head;
int main()
{
	int c,i,pos;
		
		
	while(1)
	{
		printf("\n1. Create a list\n");
		scanf("%d",&c);
		switch(c)
		{
			case 1:
				head=create(head);
				break;
         }
     }
     return 0;
}

node *create(node *l)
{
	if(l==NULL)
	{
		l=(node *)malloc(sizeof(node));
		printf("Enter a data : ");
		scanf("%d",&l->i);
		l->next=l;		
	}
	return l;
}
softetechnologies
Sort the List Elements - Link List in C Insert a node into a Circular Singly linked list
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Sri Sri Ramakrishna Paramahamsa
The world is needed a mixture of truth and make-believe. Discard the make-believe and take the truth.
Sri Sri Ramakrishna Paramahamsa
2386
57.29
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     43549
01/01/2018     36484
25/06/2018     35496
28/06/2017     34549
02/08/2017     32981
01/08/2017     27462
06/07/2017     27211
15/05/2017     26844
14/07/2017     22460
21/04/2018     21110
softetechnologies