Chep1 C Code Dsu
Chep1 C Code Dsu
h>
#include<stdlib.h>
int data;
} node;
node *create();
int op, x;
do {
printf("\n\n1)Create\n2)Insert(beginning)\n3)Search");
printf("\n4)Display\n5)Quit");
scanf("%d", &op);
switch(op) {
case 1:
head = create();
break;
case 2:
break;
case 3:
scanf("%d", &x);
search(head, x);
break;
case 4:
print(head);
break;
} while(op != 5);
node *create() {
int i, n, x;
scanf("%d", &n);
scanf("%d", &x);
if(head == NULL) {
p = head = (node*)malloc(sizeof(node));
head->next = NULL;
head->data = x;
} else {
p->next = (node*)malloc(sizeof(node));
p = p->next;
p->data = x;
p->next = NULL;
return(head);
node *p;
p = (node *)malloc(sizeof(node));
p->data = x;
p->next = head;
head = p;
return(head);
printf("\n");
while(head != NULL) {
head = head->next;
}
}
int i = 1;
head = head->next;
i++;
if(head == NULL) {
} else {