# Create circular linked list by R4R Team

What is Circular Linked List ?
Basically, It is similar as singly Linked List but the only difference is that the last Node of circular linked list is point to the first Node of the Linked List.

program-

#include< stdio.h>
#include< conio.h>
#include< alloc.h>
struct node
{
int data;
struct node *next;
};
struct node *first;

void create()
{
struct node *ptr,*cpt;
char ch;
cpt=(struct node*)malloc(sizeof(struct node));
printf("Enter Number\n");
scanf("%d",&cpt->data);
first=cpt;
do
{
ptr=(struct node*)malloc(sizeof(struct node));
printf("Enter Number\n");
scanf("%d",&ptr->data);
cpt->next=ptr;
cpt=ptr;
printf("Continue(y/n)?n");
ch=getch();
}while(ch=='y');
cpt->next=first;
}

void traverse()
{
struct node *ptr=first;
while(ptr->next!=first)
{
printf("%d ",ptr->data);
ptr=ptr->next;
}
printf("%d",ptr->data);
}

void main()
{
clrscr();
create();
traverse();
getch();
}

output-

Enter Number
2
Enter Number
4
Continue(y/n)?
Enter Number
1
Continue(y/n) ?
Enter Number
9
Continue(y/n) ?
Enter Number
0
Continue(y/n) ?
2 4 1 9 0

-In this program, we have a two function create() and traverse()
-create() function are used to create a Circular Linked List
-traverse() function are used to traverse the circular linked list.