Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions