Write a function void print_int_list that is given a single argument that is a p
ID: 3572621 • Letter: W
Question
Write a function void print_int_list that is given a single argument that is a pointer to a struct int_node. The function should print the values in the linked of integers indicated by that pointer to the standard output and continue to follow the linked list until a NULL pointer is found.
The following C structure has been defined struct int node int value; struct int node next Write a function void print int st that is given a single argument that is a pointer to a struct int node. The function should print the values in the linked of integers indicated by that pointer to the standard output and continue to follow the linked list until a NULL pointer is found. Each integer should be printed as a decimal number, one entry per line. You should not provide the main function only implement the print int st(struct int node *ptr) function as described above Answer: CheckExplanation / Answer
//function definition to print the values of linked list
void print_in_list(struct int_node *ptr)
{
//assign ptr to another pointer to visit each node in list
struct int_node *cur = ptr;
//variable to hold node number
int i = 1;
//go through each node and print value till cur pointer equals to NULL
while (cur != NULL)
{
printf("Value at node%d = %d ", i++, cur->value);
cur = cur->next;
}
}
--------------------------------------------------------------------------------
output:
Value at node1 = 3
Value at node2 = 1
Value at node3 = 9
Value at node4 = 6
Value at node5 = 10
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.