subject

Consider the following code segment:

int counter = 5;
int sum = 0;
while(counter < 10)
{
sum+= counter;
counter+=2;
}

Which of the following for loops would return the same value if System. out. println(sum) were printed?

I.

int sum = 0;
for(int i = 0; i < 3; i++)
{
sum += i;
}

II.

int sum = 11;
for(int i = 0; i < 5; i ++)
{
sum+=i;
}

III.

int sum = 0;
for(int i = 5; i < 10; i+=2)
{
sum +=i;
}

IV.

int counter = 5;
int sum = 0;
for(int i = counter; i < 10; i+=2)
{
sum+= counter;
}

III only

II, III and IV

II only

II and III

III and I

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:00
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
List the five on-board vehicle subsystems
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
How can a user delete a drawing object
Answers: 1
question
Computers and Technology, 23.06.2019 09:10
Effective character encoding requires standardized code. compatible browsers. common languages. identical operating systems.
Answers: 1
You know the right answer?
Consider the following code segment:

int counter = 5;
int sum = 0;
while(cou...
Questions
question
Mathematics, 04.03.2021 14:00
question
Mathematics, 04.03.2021 14:00
question
Mathematics, 04.03.2021 14:00
question
Mathematics, 04.03.2021 14:00
question
Mathematics, 04.03.2021 14:00
question
Mathematics, 04.03.2021 14:00
question
Business, 04.03.2021 14:00
Questions on the website: 13722367