Computer Science, asked by maunisijan, 5 months ago

Give the output of the given program segments:- [2 X 2 =4]
(a). int x;
for(x=1; x<=15; x=x+3)
{
if(x % 2 = = 0)
System.out.println(x);
}

Answers

Answered by srakebr
0

Answer:

4

10

Explanation:

at start x=1 when divided by zero remainder does not equal zero (condition not met)

value of x=1+3=4 when divided by zero remainder equals zero, hence printed

value of x=4+3=7 when divided by zero remainder does not equal zero

x=7+3=10 when divided by zero remainder equals zero, hence printed

x=10+3=13 when divided by zero remainder does not equal zero

x=13+3=16 loop ends.

Similar questions