benchmarks.wiki / Public workspace

MMLU / A programmer wrote the program below. The program uses a list of numbers called…

Problem

Answer published by the source. Consult the official source to check your work against its answer.

question

A programmer wrote the program below. The program uses a list of numbers called numList. The program is intended to display the sum of the numbers in the list.
 sum ← numList [1]
 FOR EACH value IN numList
 sum ← sum + value
 DISPLAY sum
 In order to test the program, the programmer initializes numList to [0 , 1 , 4 , 5]. The program displays 10, and the programmer concludes that the program works as intended. Which of the following is true?

choices

  1. The conclusion is correct; the program works as intended.
  2. The conclusion is incorrect; the program does not display the correct value for the test case [0, 1, 4, 5].
  3. The conclusion is incorrect; using the test case [0, 1, 4, 5] is not sufficient to conclude the program is correct.
  4. The conclusion is incorrect; using the test case [0, 1, 4, 5] only confirms that the program works for lists in increasing order.

subject

high_school_computer_science

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import