Question: What missing code should be added to this class to ensure that calling sum _ of _ even ( { 1 , 2 , 3

What missing code should be added to this class to ensure that calling sum_of_even({1,2,3,4}) returns 6?
class TEST
feature
sum_of_even(arr: ARRAY[INTEGER]): INTEGER
local
sum: INTEGER
i: INTEGER
do
sum :=0
from
i :=1
until
i > arr.count
loop
if ____ then
sum := sum + arr.item(i)
end
i := i +1
end
Result := sum
end
end
Question 8Answer
a.
arr.item(i)\\2=0
b.
arr.item(i) mod 2!=1
c.
arr.item(i)%2==0
d.
arr.item(i) mod 2=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 Programming Questions!