Question: C Programming - Linked list 1. Write a recursive function that accepts a Node pointer (i.e. a list of Node ) as a parameter, and

C Programming - Linked list

1. Write a recursive function that accepts a Node pointer (i.e. a list of Node) as a parameter, and prints all of the int values in the list.

Here is my code, it is not working and displaying nothing. Please show me the errors and correct code. Thanks.

#include #include

typedef struct Node { int value; struct Node* next; } Node;

void Print(Node* node) {

if (node == NULL) return; printf("%d ", node->value); Print(node->next); }

int main(void) { Node* list1; Node* list2; Node* list3; Node* list4; Node* list5; list1->next = list2; list2->next = list3; list3->next = list4; list4->next = list5; list5->next = NULL;

list1->value = 1; list2->value = 2; list3->value = 3; list4->value = 4; list5->value = 5;

Print(list1);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!