Question: Problem 2: Correct the code [20 Points] The function Addodd takes as input the head pointer of a linked list of integers. A Node has
![Problem 2: Correct the code [20 Points] The function Addodd takes](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3ad99cb86c_72166f3ad99605b9.jpg)
Problem 2: Correct the code [20 Points] The function Addodd takes as input the head pointer of a linked list of integers. A Node has two fields: data (int) and a pointer to a Node called next. This function checks all the nodes one by one, and adds all the odd integers. There are five errors in the below code. Identify them, and correct the code. Write your answer in the second table. = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 int Addodd (struct Node * head) { struct Node temp head; int sum = 0; if (head == NULL) { printf("List is empty!"); return 0; } while (temp == NULL) { if (temp->data82 0) Sum = sum + temp.data; temp = temp + 1; } return sum; } Your answer: Line Corrected code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
