86.3k views
1 vote
Choose which three values should replace the blanks in the for loop so that it loops through the numbers: 3 6 9 12 15.

Note that the choices will fill in the three blanks in the order which they appear.

for(int i = ______ ; i ______ ; i ______ )
{
System.out.print(i + " ");
}

0, <= 10, += 3
0, < 15, += 3
3, <= 15, ++
3, < 15, += 3
3, <= 15, += 3

1 Answer

3 votes

Answer:

3, <= 15, +=3

Step-by-step explanation:

Required.

Fill in the gaps

The given code snippet written in Java programming language is an iterative statement that prints from 3 to 15 (both inclusive) with an increment of 3.

This means that, the beginning of the loop is 3 and is represented by i = 3

Also, the end is 15 and this can be represented by i<=15.

This means that all numbers less than or equal to 15 be printed

And the increment is 3.

This can be represented in two ways.

i+=3 or i = i + 3

But as used in the options, we go with i+=3

This means that each interval is separated by 3

So, the loop when filled with the above statements is:

for(int i = 3; i <=15; i+=3)

{

System.out.print(i+" ");

}

User Shubhamoy
by
5.0k points