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 13:00
Write a program which asks you to enter a name in the form of first middle initial last. so you might enter for example samuel p. clemens. use getline to read in the string because it contains spaces. also, apparently the shift key on your keyboard doesn’t work, because you enter it all lower case. pass the string to a function which uses .find to locate the letters which need to be upper case and use toupper to convert those characters to uppercase. the revised string should then be returned to main in the form last, first mi where it will be displayed.
Answers: 1
question
Computers and Technology, 22.06.2019 15:00
Who is the first president to use social media as part of his campaign strategy
Answers: 1
question
Computers and Technology, 24.06.2019 22:30
The a great imaginary circle, or reference line, around earth that is equally distant from the two poles and divides earth into the northern and southern hemispheres.
Answers: 1
question
Computers and Technology, 25.06.2019 16:30
If your job involves creating a positive image for a company in the media, what would your job description be?
Answers: 1
You know the right answer?
Consider the following code segment:

int counter = 5;
int sum = 0;
while(cou...
Questions
question
Mathematics, 07.10.2019 03:00
question
Physics, 07.10.2019 03:00
question
History, 07.10.2019 03:00
Questions on the website: 13722360