-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCIRLL3.C
More file actions
47 lines (46 loc) · 662 Bytes
/
Copy pathCIRLL3.C
File metadata and controls
47 lines (46 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//to insert at the beginning of a circular linked list
#include<stdio.h>
#include<conio.h>
struct node {struct node *next;int data;};
struct node *head=NULL;
void append(int num)
{
struct node *temp,*p;
p=(struct node *)malloc(sizeof(struct node));
p->data=num;
if(head==NULL)
{ p->next=p;
head=p;}
else
{ struct node *x;
x=head;
p->next=head;
while(x->next!=head)
{
x=x->next;}
head=p;
x->next=head;
}
}
void display()
{
struct node *temp;
temp=head;
printf("\t %d",temp->data);
temp=temp->next;
while(temp!=head)
{
printf("\t %d",temp->data);
temp=temp->next;
}
}
void main()
{
clrscr();
append(80);
append(68);
append(78);
printf("\n");
display();
getch();
}