Question: I need to create a function definition that adds all the even positive integers in an array, but that also skips over the positive odd

I need to create a function definition that adds all the even positive integers in an array, but that also skips over the positive odd numbers in the array. I was told that I need to skip over the odd numbers in the array and not just return 0 when they occur, but I'm not sure how to do this.

How do you skip over an element (the odd numbers) in an array?

Any help would be very appreciated

Here are the Instructions for the function:

// This function will add all the even positive numbers in myArray. // The length of myArray is defined by arrayLength. // The value returned is the sum of all the even positive numbers in the array. // If there are no positive even integers in the array then return 0. // If arrayLength is zero or negative then return 0. // You can only access the bounds of myArray, that is you only access between // index 0 and index arrayLength-1.

This function is to be created in C++ by the way.

I need to create a function definition that adds all the even

Thank you

Bint addEvenPositive(int myArray[], int arrayLength) 51 52 53 54 //Integer Index variable and Integer Sum variable int sum = 0; //If condition testing if arrayLength is a nonzero postive number 56 57 58 59 60 61 62 63 64 65 if (arrayLength || arrayLength e) return 0 //Else condition testing if myArray[i] is a positive even number, and if so return the sum of all of the even numbers else //For loop going through each index in the array, as long as the index is less than arrayLength for (i 0; i

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!