Must be done in c language with linux mint On March 26, 1945 U.S. Marines raised
ID: 3738483 • Letter: M
Question
Must be done in c language with linux mint On March 26, 1945 U.S. Marines raised the U.S. flag atop Mount Suribachi, during the Battle of Iwo Jima. Write a program that uses a pointer-based linked list. You should use the following struct (declared as a global): struct node { int data; struct node *next; }; Your program must use a for loop to count from 0 to 9. Your program must insert these into a linked list such that they can be retrieved in low-to-high order (note that the example in class retrieved in high-to-low order). Your program must display the results using the following code (from class) without any modifications: while (current) { printf("%d ", current->data); current = current->next ; } Next, your program must prompt the user for a value and call a linear search function to find that value. If the value is found, your program must print out the value. You must use this code to print the value printf("[%d %d] ", search, searchList(search, head)->data); and this prototype for the search function: link *searchList(int value, link *head) Your program must also correctly free all links of the list.
Explanation / Answer
Hi, Please find my implementation of "search" method:
link *searchList(int value, link *head) {
link *current = head;
while (current) {
if(current->data == value)
return current;
current = current->next ;
}
return NULL;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.