1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AfilCa [17]
3 years ago
8

A programmer wrote the code segment below to display the average of all the elements in a list called numbers. There is always a

t least one number in the list. text... The programmer wants to reduce the number of operations that are performed when the program is run. Which change will result in a correct program with a reduced number of operations performed?
Computers and Technology
1 answer:
mestny [16]3 years ago
3 0

Answer:

Swap codes in line 7 and 8

Explanation:

The code segment below

Line 1: count ← 0

Line 2: sum ← 0

Line 3: FOR EACH value IN numbers

Line 4: {

Line 5: count ← count + 1

Line 6: sum ← sum + value

Line 7: average ← sum / count

Line 8: }

Line 9: DISPLAY (average)

The above code will make the program translator calculate the average value at each iteration.

This will take a longer time to execute and also means more instructions for the program translator.

Swapping line 7 and 8 will reduce the number of instructions to execute. This will have an instant effect on the time taken to execute the program.

Swapping line 7 and 8 means that, the program translator will only calculate the average after it must have finished calculating the sum of the values in the iteration statement.

You might be interested in
The dome of Hagia Sophia rests on these curving, triangular features of Byzantine architecture called __________.
kipiarov [429]

Answer:

pendentives

Explanation:

4 0
3 years ago
An example of a current disruptive technology is a?
guapka [62]
Smart Watches are taking over normal watches. They are getting WAYYY cheaper. There is one for about $14
6 0
3 years ago
Read 2 more answers
This is your code.
Tju [1.3M]

Answer:

dog

Explanation:

Given the code :

>>> A = [21, 'dog', 'red']

>>> B = [35, 'cat', 'blue')

>>> C = [12, 'fish', 'green']

>>> E = [A, B, C]

the value of E[0][1]

Here, square boxes is used to select the value at E[0] ; the output is then used to select the value at index 1 of E[0] output.

Note that, indexing starts at 0; hence first list element is 0, then, 1, 2, and so on.

At

E[0] ; list E, index 0 (first element in the list) , gives an output A

Then, A[1] ; list A, index 1 (second element in the list) gives 'dog'

4 0
3 years ago
What is the output of the program?
Sergio [31]

Answer:

the output of the above program is

2 3

3 5

8

Explanation:

It seems the program is trying to pair two numbers into one and leaving the unpaired number (in a case of odd number of numbers) as a separate output.

This is why numbers 2 and 3 form 23, numbers 3 and 5 form 35 and 8 is another output of the program.

5 0
3 years ago
Write a for loop that prints the integers 50 through 1, each on a separate line. use no variables other than count.
Anton [14]
For( count = 50; count > 0; count-- )
    System.out.println( count );
5 0
3 years ago
Other questions:
  • A measure of the twisting or rotational force that an engine can produce is called
    12·1 answer
  • True or false the primary advantage of the worksheet is the ability to solve numerical problems quickly and accurately
    11·1 answer
  • On sites that use "cloud computing," how is your information being stored?
    13·1 answer
  • What can act as a buffer against unemployment
    11·1 answer
  • Which of the following is a valid HTML reference to a CSS file?
    13·1 answer
  • Which of the following is NOT an algorithm?
    15·1 answer
  • Which spreadsheet feature could the scholarship committee use to locate applicants who meet the criteria?
    10·1 answer
  • 1. What does the term 'in season' mean?
    15·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    7·1 answer
  • In what way, if any, is the impact of a given risk affected by the timing of a project?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!