Write a function to return the value at nth position in a linked list. Start ind
ID: 3907333 • Letter: W
Question
Write a function to return the value at nth position in a linked list. Start indexing at zero. The function takes two arguments: the linked list head and the position to search for. Return the value at that position. Return-1 if the position is not found. int LinkedListNthNode(node head, int position) The linked list structure: struct node int value node *next; f; The following code will run to test your function: int output LinkedListNthNode (head, position); coutExplanation / Answer
int LinkedListNthNode(node *head, int position) { int i = 0; node *temp = head; while(temp != NULL) { if(i == position) { return temp->value; } temp = temp->next; i++; } return -1; }