Computers and Technology
Computers and Technology, 05.05.2020 10:40, KIAZTUNEZ

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?

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

{

total += k + 1;

}

A

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

{

total += k - 1;

}

B

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

{

total += k + 1;

}

C

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

{

total += k + 1;

}

D

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

{

total += k - 1;

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:00, ruddymorales1123
What allows you to create a wireless connection among your smart devices
Answers: 2
image
Computers and Technology, 24.06.2019 00:30, petergriffin6772
Which boolean operator enables you to exclude a search term? a} not b} and c} or d} plus
Answers: 1
image
Computers and Technology, 24.06.2019 02:10, trint5952
Aspeed limit sign that says "night" indicates the legal speed between sunset and sunrise.
Answers: 2
image
Computers and Technology, 24.06.2019 06:30, toolazytobehuman
Me and category do i put them in because this is science
Answers: 1
Do you know the correct answer?
Consider the following code segment.

int total = 0;

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

Questions in other subjects: