#include #include typedef struct st_info { char name[50]; int roll; struct st_info *next; } data; data *head = NULL; data *list = NULL; display() { list = head; while(list != NULL) { printf("%s\n",list -> name); printf("%d\n",list -> roll); list = list -> next; } } void make_node(int n) { int i; if(n==0) { head == NULL; } else { for(i=0; i name); scanf("%d",&N -> roll); N -> next = NULL; if(head == NULL) { head = N; list = head; } else { list -> next = N; list = list -> next; } } } } void add_in_last() { list = head; data *p = (data*)malloc(sizeof(data)); scanf(" %[^\n]s",p -> name); scanf("%d",&p -> roll); p -> next = NULL; while(list -> next!= NULL) { list = list -> next; } list -> next = p; } void insert_at_first() { data *q = (data*)malloc(sizeof(data)); scanf(" %[^\n]s",q -> name); scanf("%d",&q -> roll); list = head; if(head == NULL) { head = q; } else { q -> next = head; head = q; } } void insert_in_nth(int n) { data * temp = NULL; int count = 0; list = head; data *r = (data*)malloc(sizeof(data)); scanf(" %[^\n]s",r -> name); scanf("%d",&r -> roll); r -> next = NULL; if(head == NULL) { head = r; } else { while(list != NULL) { temp = list -> next; count++; if(count == n) { list -> next = r; r -> next = temp; } list = list -> next; } } } void delete_by_pos(int n) { int i; data *temp1=head; if(n==1) { head = temp1->next; free(temp1); return; } for(i=1; i next; } data *temp2 = temp1 -> next; temp1 -> next = temp2 -> next; free(temp2); } void delete_by_valu(int n) { data *list = head; data *temp1=list; while(list!=NULL) { if(head -> roll ==n) { head = temp1 -> next; free(temp1); return; } else { if(list -> roll == n) { data *temp2 = temp1 -> next; temp1 -> next = temp2 -> next; free(temp2); return; } temp1 = list; list = list -> next; } } } void search_by_pos(int n) { data *list = head; int i; //data *temp = list; for(i=1;i next; } printf("%s\n",list -> name); } void search_by_valu(int n) { data *list = head; while(list !=NULL) { if(list -> roll = n ) { printf("%s",list -> name); return; } else list = list -> next; } } main() { int n,m,x,y,z,h; scanf("%d",&n); printf(".............\n"); make_node(n); printf(".............\n"); display(); printf(".............\n"); add_in_last(); printf(".............\n"); display(); printf(".............\n"); insert_at_first(); printf(".............\n"); display(); printf(".............\n"); scanf("%d",&m); insert_in_nth( m); printf(".............\n"); display(); printf(".............\n"); scanf("%d",&x); delete_by_pos(x); printf(".............\n"); display(); scanf("%d",&y); delete_by_valu(y); printf(".............\n"); display(); printf(".............\n"); scanf("%d",&z); search_by_pos(z); printf(".............\n"); scanf("%d",&h); search_by_valu(h); }