67,673 views
39 votes
39 votes
A summer camp offers a morning session and an afternoon session. The list morningList contains the names of all children attending the morning session, and the list afternoonList contains the names of all children attending the afternoon session.

Only children who attend both sessions eat lunch at the camp. The camp director wants to create lunchList, which will contain the names of children attending both sessions.
The following code segment is intended to create lunchList, which is initially empty.

It uses the procedure IsFound (list, name), which returns true if name is found in list and returns false otherwise.



FOR EACH child IN morningList

{



}

Which of the following could replace so that the code segment works as intended?
(A)
IF (IsFound (afternoonList, child))

{

APPEND (lunchList, child)

}

(B)
IF (IsFound (lunchList, child))

{

APPEND (afternoonList, child)

}
(C)
IF (IsFound (morningList, child))

{

APPEND (lunchList, child)

}

(D)
IF ((IsFound (morningList, child)) OR

(IsFound (afternoonList, child)))

{

APPEND (lunchList, child)

}

User Gcswoosh
by
2.6k points

1 Answer

30 votes
30 votes

Answer:

The answer is "Option A".

Step-by-step explanation:

In this question, the choice "A" is correct because in this a conditional if block statement is used that that use "IsFound" method that takes two parameters "afternoonList and Child" in its parameter and use the append method that takes "lunchList and child" in parameter and add values, that's why other choices are wrong.

User Shawnr
by
2.8k points