subject

Consider the following code segment.

int total = 0;

for (int k = 0; k < = 100; k += 2)

{

total += k;

}

which of the following for loops could be used to replace the for loop in the original code segment so that the original and the revised code segments store the same value in total?

a. for (int k = 0; k < 100; k += 2)

{

total += k + 1;

}

b. for (int k = 1; k < 101; k += 2)

{

total += k - 1;

}

c. for (int k = 0; k < = 101; k += 2)

{

total += k + 1;

}

d. for (int k = 1; k < = 101; k += 2)

{

total += k + 1;

}

e. for (int k = 1; k < = 101; k += 2)

{

total += k - 1;

}

ansver
Answers: 1

Another question on Advanced Placement (AP)

question
Advanced Placement (AP), 24.06.2019 02:30
How american was colonial art? to what extent does it illustrate the development of a new society
Answers: 1
question
Advanced Placement (AP), 25.06.2019 11:00
Which are the apprehensions of the consumers who shop online? consumers who shop online enjoy the convenience of shopping from home but are apprehensive about theft and loss of privacy.
Answers: 1
question
Advanced Placement (AP), 26.06.2019 00:10
What is the correct way to represent 5600 l using scientific notation? a)-5.6 x 1034 b)-5.6 x 10-3 l c)5.6 x 10-3l d)5.6 x 103 l
Answers: 2
question
Advanced Placement (AP), 26.06.2019 22:30
When members of congress must vote on a bill that is nonideological of one on which they have no specific position what are the most powerful influences
Answers: 1
You know the right answer?
Consider the following code segment.

int total = 0;

for (int k = 0; k <...
Questions
question
English, 20.12.2020 03:30
question
Arts, 20.12.2020 03:30
question
English, 20.12.2020 03:30
question
Mathematics, 20.12.2020 03:30
Questions on the website: 13722361