39. If a programmer tested the following code with the values indicated, would the program cor- rectly calculate the average of the test scores? Assume all variables and lists have been appro- priately initialized. FOR EACH score IN testScores { IF score> 0 ( total total } count count 1 } DISPLAY ("The average score on the test was: ", total / count) 80, 85, 50, 0, Test1 [100, 90, 80, 85, 90) Test2 [192, 85, 74, 100, 96, 88] score (A) Yes, the code works as it should for both test cases. (B) No, the code does not average the test scores correctly for either test. (C) No, the code only works for the Testl scores. (D) No, the code only works for the Test2 scores. 40. When should a heuristic algorithm be used? (A) When a problem is unable to process in reasonable time but a "close enough" solu- tion is acceptable (B) When the data is not sorted and cannot be placed in the order needed (C) When a problem is undecidable because not enough information is known (D) When searching is needed but efficiency is a requirement 41. How many times do FOR EACH loops run with lists? (A) Once (B) Until the index for the list is 0 (C) For the LENGTH of the list (D) Until the user types STOP

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question
Please answer this questions explain and show work please
39. If a programmer tested the following code with
the values indicated, would the program cor-
rectly calculate the average of the test scores?
Assume all variables and lists have been appro-
priately initialized.
FOR EACH score IN testScores
{
IF score>0
(
}
total total score
count count 1
DISPLAY ("The average score on
the test was: ", total / count)
Test1 [100, 90, 80, 80, 85, 50, 0,
85, 90)
Test2 [192, 85, 74, 100, 96, 881
(A) Yes, the code works as it should for both
test cases.
(B) No, the code does not average the test
scores correctly for either test.
(C) No, the code only works for the Testl
scores.
(D) No, the code only works for the Test2
scores.
40. When should a heuristic algorithm be used?
(A) When a problem is unable to process in
reasonable time but a "close enough" solu-
tion is acceptable
(B) When the data is not sorted and cannot be
placed in the order needed
(C) When a problem is undecidable because
not enough information is known
(D) When searching is needed but efficiency is
a requirement
41. How many times do FOR EACH loops run
with lists?
(A) Once
(B) Until the index for the list is 0
(C) For the LENGTH of the list
(D) Until the user types STOP
Transcribed Image Text:39. If a programmer tested the following code with the values indicated, would the program cor- rectly calculate the average of the test scores? Assume all variables and lists have been appro- priately initialized. FOR EACH score IN testScores { IF score>0 ( } total total score count count 1 DISPLAY ("The average score on the test was: ", total / count) Test1 [100, 90, 80, 80, 85, 50, 0, 85, 90) Test2 [192, 85, 74, 100, 96, 881 (A) Yes, the code works as it should for both test cases. (B) No, the code does not average the test scores correctly for either test. (C) No, the code only works for the Testl scores. (D) No, the code only works for the Test2 scores. 40. When should a heuristic algorithm be used? (A) When a problem is unable to process in reasonable time but a "close enough" solu- tion is acceptable (B) When the data is not sorted and cannot be placed in the order needed (C) When a problem is undecidable because not enough information is known (D) When searching is needed but efficiency is a requirement 41. How many times do FOR EACH loops run with lists? (A) Once (B) Until the index for the list is 0 (C) For the LENGTH of the list (D) Until the user types STOP
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,