For Loops Worksheet
By Mickey Arnold
starstarstarstarstarstarstarstarstarstar
Last updated 10 months ago
5 Questions
DIRECTIONS : Fill in each blank with the correct answer/output. Assume each statement happens in order and that one statement may affect the next statement.
Some sections might print more than once.
1 point
1
Question 1
1.
for(int i=-3; i<19; i=i+3){ out.print(i + " ");}
for(int i=-3; i<19; i=i+3)
{
out.print(i + " ");
}
1 point
1
Question 2
2.
for(int j=17; j>-2; j=j-2){ out.print(j + " ");}
for(int j=17; j>-2; j=j-2)
{
out.print(j + " ");
}
1 point
1
Question 3
3.
for(int x=20; x<50; x=x+3){ out.print(x + " ");}
for(int x=20; x<50; x=x+3)
{
out.print(x + " ");
}
1 point
1
Question 4
4.
for(int m=37; m>0; m=m-4){ out.print(m + " ");}
for(int m=37; m>0; m=m-4)
{
out.print(m + " ");
}
1 point
1
Question 5
5.
int total=0;for(int s=1; s<19; s++){ total=total+s;}out.println(total);
int total=0;
for(int s=1; s<19; s++)
{
total=total+s;
}
out.println(total);