Computer Science, asked by prasenjitsaha9005, 6 months ago

iv) What will be the output by the following code segment?
int sum=0;
int count=1;
while(count<5)
{
sum=sum+count;
count=count+2;
}
System.out.println(sum);​

Answers

Answered by riyaamen303
5

Answer:

The output will be 4.

Hope this helps you.Please add Brainliest if it is correct.

Answered by anushkamishra7369
0

Answer:

The correct answer will be 6

as first sum=0

then sum = 2

then sum =4.

and in value of count first it is 2 then it is 4 and after 6 the loop will not execute and comes out of the loop

Explanation:

hope its help....

Similar questions