# Create and Traverse Circular linked list

1. create a node template with the basic code given below.
struct cll
{
int data;
struct cll *next;
};

*next pointer hs address of the next node for the actual current node.

2.use typedef keyword to create an alias name for structure cll (data type).here in the below code new datatype known as node is created using the typedef keyword

typedef struct cll node;
1. write a function for creating a newnode using malloc function and taking node data value from the user with in the function
node* getnode()
{
node * newnode;
newnode = (node *) malloc(sizeof(node));
printf("\n Enter data: ");
scanf("%d", &newnode -> data);
newnode -> next = NULL;
return newnode;
}

In the above code getnode() function returns the node type of pointer, it returns the newnode from the function .when the getnode function is called in the program this creates a node in the memory.

4.create a *head pointer and assign NULL

1. create two more pointers known as *newnode,*temp inside createnodes function, use FOR loop for condition (i<no of nodes).

6.call getnode( ) function for the newnode pointer ,inside for loop

newnode = getnode();
1. create a if block for condtion (head==NULL) then assign newnode to the head

for the else block

use while condition (temp->next!=NULL),so that the temp will be at the last or if there is only one node the temp pointer will be there in the first place

if there are more then one nodes,this while condition is useful ,inside while loop change temp from one node to next node until it points to last node

while(temp -> next!=NULL)
temp = temp -> next;

10.link next address of temp node to newnode (temp -> next = newnode)

12.last node is pointing to starting node,this is circular list

### Program to Create Circular linked list#

void createlist(int n)
{
int i;
node *newnode;
node *temp;
for(i = 0; i < n ; i++)
{
newnode = getnode();
{
}
else
{
while(temp -> next != NULL)
temp = temp-> next;
temp -> next = newnode;
}
}
newnode ->next = head; /* last node is pointing to starting node */
}

1. create a *temp pointer from node structure, initialize this temp pointer with head
1. move temp pointer to next node in linked list ,move temp pointer by replacing next nodes address (temp=temp->next ) until the condition (temp!=head)

3.display each nodeâ€™s data

### Program to Traverse Circular linked list#

void traverse()
{
node *temp;
printf("\n The contents of List (Left to Right): ");