-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDEL_BESE.C
More file actions
114 lines (88 loc) · 1.36 KB
/
DEL_BESE.C
File metadata and controls
114 lines (88 loc) · 1.36 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include<stdio.h>
#include<conio.h>
struct node
{
int info;
struct node* next;
};
typedef struct node* nodep;
nodep del_value(nodep);
nodep add();
nodep create();
void display(nodep);
void main()
{
nodep start=NULL;
clrscr();
start=add();
start=del_value(start);
display(start);
getch();
}
nodep add()
{
nodep t,t1,start=NULL;
char ch;
printf("Creation of list\n");
do{
t=create();
if(start==NULL)
start=t;
else
t1->next=t;
t1=t;
printf("Do you want to add more\n");
scanf(" %c",&ch);
}while(ch=='Y'|| ch=='y');
return start;
}
nodep create()
{
nodep t;
t=(nodep)malloc(sizeof(struct node));
if(t==NULL)
{
printf("Overflow\n");
exit(0);
}
t->next=NULL;
printf("Enter Data\n");
scanf("%d",&t->info);
return t;
}
void display(nodep t)
{
printf("\nList is::->\n");
while(t!=NULL)
{
printf("%d\t",t->info);
t=t->next;
}
}
nodep del_value(nodep start)
{
nodep temp,temp1=NULL;
int value,count=1;
printf("Enter value that you want delet\n");
scanf("%d",&value);
temp=start;
while(temp!=NULL && temp->info!=value)
{
temp1=temp;
temp=temp->next;
count++;
}
if(temp!=NULL)
{
if(count==1)
start=temp->next;
else
temp1->next=temp->next;
temp->next=NULL;
printf("%d Delet at position=%d",value,count);
free(temp);
}
else
printf("%d not found\n",value);
return start;
}