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
BARSIC [14]
3 years ago
7

Assume that you have an array of integers named arr. The following program segment is intended to sum arr [0]through arr[n−1], w

here n = arr.length: sum = 0; i = 0; n = arr.length; while (i != n) { i++; sum += arr[i]; } In order for this segment to perform as intended, which of the following modifications, if any, should be made?
Computers and Technology
1 answer:
Paladinen [302]3 years ago
7 0

Answer:

There is only one modification in the above loop i.e. while loop should be like this--

while (i != n)

     {

         sum+=arr[i];   // Line 1, In question segment it is line 2.

          i++;                // Line 2,  In question segment it is line 1.

     }

Output:

Now if the array input is 1,2,3,4,5 then the output is 15.

Explanation:

In the above question, all the line of the segment is right except the body of the loop because--

  • The First line of the loop is increment statement which increments the value of "i" variable from 1 and the value of "i" variable will be 1 in the first iteration of the loop
  • The second line starts to add the value from 1'st index position of the array. Hence the segment gives the wrong answer. It adds the arr[1] to arr[n-1].
  • So I interchanged both lines of the while loop as shown in the answer part. I make the line 1 (In question segment) as line 2(In answer part) and line 2 (In question segment) as line 1 (In answer part).

Now It gives the correct output because it can add arr[0] to arr[n-1].

You might be interested in
_____ includes a wide range of applications, practices, and technologies for the extraction, transformation, integration, analys
Alla [95]

Answer:

The answer is "Option a".

Explanation:

The B.I. is a method, methodology, software, and development set that makes raw data usable and relevant, which facilitates improved decision-making and competitive opportunities, and certain choices were wrong, which can be described as follows:

  • In option b, The A.I is uses in the machines, that's why it is not correct.
  • In option c, It is used to analyze the data, which used in business. that's why it is not correct.
  • In option d, It is wrong, because it a part of A.I.
6 0
3 years ago
A keyboard, mouse, and microphone are examples of ________.
kykrilka [37]

Answer:

A keyboard, mouse, and microphone all are examples of <u>peripheral devices.</u>

Explanation:

hope this helps

5 0
2 years ago
Read 2 more answers
3.5 lesson practice quiz Edhesive
erik [133]

Answer:

                                                                                     

Explanation:

6 0
3 years ago
Read 2 more answers
structured analysis is called a(n) _____ technique because it focuses on processes that transform data into useful information.
zzz [600]

Answer:

Process - centered technique

Explanation:

Process - centered technique -

It is the method , where the useless or waste data is converted to some useful information , is referred to as process - centered technique .

This conversion process requires some activities , like  maintenance/support  , implementation , design , analysis and  planning .

Hence , from the given information of the question,

The correct option is Process - centered technique .

4 0
3 years ago
1 Which one of the following is a transmission
ElenaW [278]

Answer:

d

Explanation:

All of the above can be means by which signals or information is transferred.

5 0
2 years ago
Other questions:
  • Your sister wants to purchase Microsoft Office 2013 for her new laptop. She doesn't want to pay for a subscription, and she want
    12·1 answer
  • The countryside presents
    11·1 answer
  • The goal expressed in this definition states that data visualization is about ________________ .
    11·2 answers
  • What is a computer OPERATING SYSTEM?
    5·1 answer
  • With _________, users will receive recommendations for items liked by similar users.
    9·1 answer
  • A soft news story and a feature story are the same thing.<br> O True<br> O False<br> HELLPP ASSAAAP
    12·2 answers
  • In a finite state machine, state transitions happen only: a. When the reset causes a clock pulse on the D outputs of the flip-fl
    11·1 answer
  • How do you get off of the comments after you look at them wit out going all the way off the app?
    15·1 answer
  • Please help me with this coding problem :)
    6·1 answer
  • A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is 50, then th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!