Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Program, assume there are a helper file and the main function implemented already Problem 1 (Mandatory) Task: Write a program that creates a linked
C++ Program, assume there are a helper file and the main function implemented already
Problem 1 (Mandatory) Task: Write a program that creates a linked list of integers and a function that sums all the even values in the list. Requirements: 1. Implement a sumEvens function: (you may change the function header below to suit your implementation) int sumEvens (Node *head); // example declaration This function should return the sum of all even integers in the list. If the list is empty, return o. Examples: * If the list is 7 -> 4 -> 6 -> 2 -> NULL, calling sumEvens (head) should return 12. * If the list is 3 -> 9 -> 2 -> NULL, calling sumEvens (head) should return 2. * If the list is NULL, calling sumEvens (head) should return o. 2. Write a main function that creates a linked list of integers, then calls the function defined in part (1) to demonstrate the method. Call it on multiple lists to show that it works in all cases, and print out the results. 3. Test your function to make sure that it works in every case, no matter how many nodes are in the linked list
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started