-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy2.txt
53 lines (45 loc) · 866 Bytes
/
copy2.txt
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
#include<stdio.h>
#include<malloc.h>
typedef struct List
{
int data;
struct List *next;
}list;
void insert_front(list **head,int num)
{
list *node=(list*)malloc(sizeof(list));
node->data=num;
node->next=*head;
*head=node;
}
void print(list *head)
{
if(head==NULL)
printf("\nEmpty List");
else
{
while(head!=NULL)
{
printf("%d -> ",head->data);
head=head->next;
}
printf("NULL");
}
}
int main()
{
int n,i,value;
list *head=NULL;
printf("\nEnter total number: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nPlease enter value: ");
scanf("%d",&value);
insert_front(&head,value);
}
printf("\n\n");
print(head);
printf("\n");
return 0;
}