-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUntitled1.cpp
More file actions
64 lines (51 loc) · 941 Bytes
/
Copy pathUntitled1.cpp
File metadata and controls
64 lines (51 loc) · 941 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node* link;
};
struct node* start = NULL;
struct node* ptr;
struct node* save;
void insert(int d)
{
struct node* new1 =(struct node*)malloc(sizeof(struct node));
new1->link = NULL;
new1->data = d;
if(start == NULL)
{
start = new1;
printf("ptr %d\n",start->data);
}
else
{
ptr = start;
while(ptr->link!=NULL)
{
ptr= ptr->link;
}
ptr->link= new1;
printf("ptr %d\n",ptr->data);
}
}
void view()
{
ptr = start;
while(ptr!=NULL)
{
printf("%d ",ptr->data);
}
}
int main()
{
int i,item;
for(i=0;i<5;i++)
{
printf("enter the number to be inserted");
scanf("%d",&item);
insert(item);
}
view();
return 0;
}