1) Write the following function: struct node *find_last(struct node *list, int n
ID: 3615098 • Letter: 1
Question
1) Write the following function: struct node *find_last(struct node *list, int n); The list parameter points to a linked list. The functionshould return a pointer to the last nodethat contains n; it should returnNULL in ndosen't appear in the list. The nodestructure is defined as (A linked listconsist of a chain of structures (callednodes), with each node containing apointer to the next node in the chain. The last node in the listcontains a null pointer. 1) Write the following function: struct node *find_last(struct node *list, int n); The list parameter points to a linked list. The functionshould return a pointer to the last nodethat contains n; it should returnNULL in ndosen't appear in the list. The nodestructure is defined as (A linked listconsist of a chain of structures (callednodes), with each node containing apointer to the next node in the chain. The last node in the listcontains a null pointer.Explanation / Answer
//Hope this will help you. #include#includestruct node{int n;struct node *next;};}int main(){struct node *f=(struct node *)malloc(sizeof(struct node));struct node *ptr;f->n=2;f->next = (struct node *)malloc(sizeof(struct node));f->next ->n=3;f->next->next=NULL;ptr = find_last(f,3);if(ptr == NULL)printf("It is not found in list");elseprintf("Value found:%d",ptr->n);printf(" ");system("pause");}Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.