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

Other questions on the subject: Advanced Placement (AP)

image
Advanced Placement (AP), 23.06.2019 19:00, tiffanyheist
Read the scenario below and answer the question that follows. bailey is plagued with sleep problems at least a couple of times a week. she often feels tired at work and doesn't do her best work because she is "just so tired." according to the lesson, it can be said that adults have some of the same problems with sleep that bailey does. a. few b. many c. no d. all
Answers: 1
image
Advanced Placement (AP), 25.06.2019 18:00, edgartorres5123
Which best explains why the number of states in the world increased significantly between 1985 and 1995? the map of southeast asia was redrawn, and new countries were formed. new states were formed when the soviet union collapsed. many african states received independence from their colonizers. communist countries seeking to spread their influence created new satellite states. civil wars in central america fueled the creation of new states.
Answers: 1
image
Advanced Placement (AP), 25.06.2019 23:00, diazsindy
Which of the following terms refers to a promise made to lenders by a borrower? question options: record covenant bargain investiture
Answers: 1
image
Advanced Placement (AP), 27.06.2019 08:30, iibabycarrotsii
Select the sequence that lists earth's layers from hottest to coolest. a. mantle, crust, core b. core, mantle, crust c. crust, core, mantle d. mantle, core, crust
Answers: 1
You know the right answer?
Consider the following code segment.

int total = 0;

for (int k = 0; k <...

Questions in other subjects:

Konu
Mathematics, 03.09.2020 22:01