subject

Assume that you have an array of integers named arr.
the following program segment is intended to sum arr [0]through arr[n−1], where 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?

a) no modification is necessary
b) sum = 0; i = 0; should be changed to sum = arr[1]; i = 1;
c) while (i ! = n) should be changed to while (i < = n)
d) sum += arr[i]; should be changed to sum += arr[i+1];
e) i++; should be interchanged with sum += arr[i];

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:30
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a.if the manual switch s is on, then the light l is on. b.besides the manual switch, there is a motion detector, m1, which activatesthis light.c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d.the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
question
Computers and Technology, 23.06.2019 09:50
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
question
Computers and Technology, 23.06.2019 14:00
What is html ? give a small description about html
Answers: 2
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
You know the right answer?
Assume that you have an array of integers named arr.
the following program segment is intende...
Questions
question
Mathematics, 06.06.2021 09:50
question
Biology, 06.06.2021 09:50
question
Mathematics, 06.06.2021 09:50
question
Mathematics, 06.06.2021 14:00
question
Biology, 06.06.2021 14:00
Questions on the website: 13722367