Create a Circular Singly linked list
22-09-2019    226 times

### 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.

### 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.

### Program

#include <stdio.h>
#include <conio.h>
{
int i;
};

//prototype declaration
node *create(node *);
int main()
{
int c,i,pos;

while(1)
{
printf("\n1. Create a list\n");
scanf("%d",&c);
switch(c)
{
case 1:
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;
}