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
Which of the following is opened when the Find command is clicked? Question 9 options: Navigation Pane Insert Hyperlink dialog b
Dima020 [189]

The element, from the following options, which is opened when the find command is clicked is the search pane.

What is find command?

Find command is the command which is used to find the list of files and their location.

Find command can be used in different manners-

  • To find the different files in a system.
  • Find command can find the files by their name, size, date or other information related to the required document.
  • This command can be modified with the requirement of the search.

The options for the given problem are-

  • Navigation Pane Insert- It is used to show the navigation pane in word or similar space.
  • Hyperlink dialog box-This open, when the insert hyperlink command is clicked.
  • Bookmark dialog box-This opens, when the bookmark command is clicked.
  • Search Pane- Search pane is opens, when the find commond is clicked.

Thus, the element, from the following options, which is opened when the find command is clicked is the search pane.

Learn more about the find command here:

brainly.com/question/25243683

4 0
2 years ago
7. Suppose that a RISC machine uses 5 register windows. a. How deep can the procedure calls go before registers must be saved in
Semenov [28]

Answer:

bbbbbbbbbbbbnbbnnnnnnnnnnnnnnnnn

6 0
2 years ago
Alt +f4 is a short cut of close a document in MS word /ture /false​
vesna_86 [32]

Answer:

True.

Explanation:

Microsoft Word refers to a word processing software application or program developed by Microsoft Inc. to enable its users to type, format and save text-based documents.

In Computer science, there are specific key combinations (short cut) that avail end users the opportunity to perform specific functions without having to go through a series of step.

For example, when you press the Alt button and function key 4 (F4) at the same time, it would close the current open window.

Hence, Alt + F4 is a short cut key that can be used to close a document in MS word.

8 0
2 years ago
How can rows be added to a table? Check all that apply.
Lubov Fominskaja [6]

Tables are used to display information in a more arranged and organized manner.  

Various ways of adding a row in an already existing table are:

1) By drawing a row in the table using the draw option.

2) By using the insert option under the Table Tools tab.

3) By designing the table with an added row using the Design tab.

<u>Explanation:</u>

In the insert option, go to the extreme right corner. There appears an option of Draw Table. Draw another row and it gets added.  

This tab contains two tabs, Design and Layout that enable you to rapidly arrange your table, embed or erase lines and sections, set the arrangement for cells, and organization the typography of the content in your table.

Thus, a table and its capacity are built up from here on and open for designing.

8 0
3 years ago
Read 2 more answers
How to resize an image in photoshop without losing quality.
castortr0y [4]

Answer:

Explanation:

Make sure resample is turned on

Turn on the chain link if you want the width and height to change together. If not, turn off the chain so that you can set your own width and height.

Choose your new size (you can choose to choose different measurement units by clicking on “inches”)

press ok

i hoped this helped!!!!!!!!

8 0
2 years ago
Other questions:
  • Sharing a workbook helps to complete ________ (A, tasks) (B,changes) (C, typing) on time. Multiple people acssessing the workboo
    9·1 answer
  • For an machine using 2-dimensional even parity for error detection/correction, and the following received bytes, where is the er
    9·1 answer
  • How many inches do a tire have to be to sometimes be refer as bald of balding tries
    14·1 answer
  • In one to two sentences, explain why citizens pay taxes
    8·1 answer
  • How can a student manage time and stress for better results in school? Check all that apply. by taking breaks while studying by
    8·2 answers
  • U $ er Ideas for R 0 B 1 0 X?
    12·2 answers
  • When you purchase donuts, they come in boxes of 12, so 24 donuts take 2 boxes. All donuts need to be in a box, so if you buy 13
    10·1 answer
  • Write the Flowchart to find Even number between 1 to 50<br>​
    9·1 answer
  • window operating system popularly known as. 1) character user interface. 2) computer user interface. 3) graphic user interface.
    15·1 answer
  • Write l for law of enrtia,ll for law of Acceleration and lll for law of enteraction.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!