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
Following Aristotle,man by nature is a political animal,justify the above claim in the light of the Russian invasion of Ukraine
fredd [130]

Following Aristotle, man by nature is a political animal using the claim in the light of the Russian invasion of Ukraine is that:

  • Aristotle stated that State is natural due to the fact that nature has not made man to be in a self-sufficient state. But Man has a lot of -different type of needs  which they want them to be fulfilled. Russian need and Ukraine need differs and as such, man is fighting to satisfy their needs.

<h3>What is the quote about?</h3>

In his Politics, Aristotle was  known to be a man who believed man to be a "political animal" due to the fact that he is a social creature that is said to have the power of speech and also one that has moral reasoning:

He sate that man is a lover of war and as such, Aristotle stated that State is natural due to the fact that nature has not made man to be in a self-sufficient state. But Man has a lot of -different type of needs  which they want them to be fulfilled. Russian need and Ukraine need differs and as such, man is fighting to satisfy their needs.

Learn more about Aristotle from

brainly.com/question/24994054

#SPJ1

3 0
2 years ago
In a three-tier architecture, the component that runs the program code and enforces the business processes is the:_______.
madam [21]

Answer:

Application Server

Explanation:

The Application Server is a component in computer engineering that presents the application logic layer in a three-tier architecture.

This functionality allows client components to connect with data resources and legacy applications.

In this process of interaction, the Application Server runs the program code from Tier 1 - Presentation, through Tier 2 - Business Logic to Tier 3 - Resources, by forcing through the business processes.

8 0
2 years ago
Write a program that determines the price of a movie ticket (similar to the one in the chapter). The program asks for the custom
goblinko [34]

Answer:

#include <iostream>

using namespace std;

int main() {

int age,time;

float price;

cout<<"Enter age:";

cin>>age;

cout<<"Enter time(in 24 hour clock for noon 1200):";

cin>>time;

if(age>13){

if(time<1700){

price=5;

}else{

price=8;

}

}else{

if(time<1700){

price=2;

}else{

price=4;

}

}

cout<<"Price: $"<<price<<endl;

}

Explanation:

Okay, here are the steps to be taken in order to be able to Write a program that determines the price of a movie ticket as given in details in the question above. Therefore, checked the steps below;

==> Input the age and the time.

==> If the age is not greater than 13, input the time(that is <1700) and follow it by imputing the price.

And if the age is greater than 13, you will also need to input the price. Just as below;

#include <iostream>

using namespace std;

int main() {

int age,time;

float price;

cout<<"Enter age:";

cin>>age;

cout<<"Enter time(in 24 hour clock for noon 1200):";

cin>>time;

if(age>13){

if(time<1700){

price=5;

}else{

price=8;

}

}else{

if(time<1700){

price=2;

}else{

price=4;

}

}

cout<<"Price: $"<<price<<endl;

}

6 0
3 years ago
A(n) ____ is a front-end processor that multiplexes the traffic from hundreds of remote terminals into one port on a large compu
Taya2010 [7]
I think it'd be terminal concentrator.  A(n) terminal concentrator is a front - end processor that multiplexes the traffic from hundreds of remote terminals into one port on a large computer. 
7 0
3 years ago
Summarize the five stages of cultural shock
Anton [14]
1. Honeymoon stage
2. Distress and anxiety
3. Adjustment
4. Adaption
5. Re-entry shock
8 0
3 years ago
Read 2 more answers
Other questions:
  • Someone who participates online for social reasons usually has a:
    9·1 answer
  • Write a Java program that prompts the user to enter a sequence of non-negative numbers (0 or more), storing them in an ArrayList
    5·1 answer
  • Yesterday you installed a new game on your computer. When you ran the computer, you noticed that the application was running ver
    15·1 answer
  • HELP URGENT
    12·2 answers
  • In which of the following situations will a macro make your work more efficient?
    9·1 answer
  • Given a variable temps that refers to a list, all of whose elements refer to values of type float, representing temperature data
    10·2 answers
  • When can we feel electricity?? Tell me the volt
    15·1 answer
  • A write once, read many (worm) disc is a common type of _____.
    6·1 answer
  • 14. Which of the following information about the ESRT T-teen rating rating is FALSE?
    15·1 answer
  • A person who creates a computer virus is a (1)system analyst (2) techician(3) programmer​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!