We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c5c05c2 commit 0fa2382Copy full SHA for 0fa2382
Linked List traversal
@@ -0,0 +1,54 @@
1
+#include<stdio.h>
2
+#include<conio.h>
3
+
4
5
+void main()
6
+ struct node
7
+ {
8
+ int data;
9
+ struct node *next;
10
+ };
11
12
+ struct node *head,*newnode,*temp;
13
14
+ head=0,temp=0;
15
16
+ int choice;
17
18
+ while (choice){
19
+ newnode = (struct node*)malloc(sizeof(struct node))
20
21
+ printf("Enter data")
22
23
+ scanf("%d",&newnode->data);
24
+ newnode->next=0;
25
26
+ if(head==0)
27
28
+ head=temp=newnode;
29
+ }
30
+ else
31
32
+ temp->next=newnode;
33
+ temp=newnode;
34
35
36
+ printf("Do you want to continue (0,1)?");
37
+ scanf("%d",&choice);
38
39
+ /////////////////displaying///////////////
40
41
42
+ temp=head;
43
+ while(temp!=0)
44
45
+ printf("%d",temp->data);
46
+ temp=temp->next;
47
48
+ getch();
49
50
51
52
53
54
0 commit comments