Test: Computer Science

Consider the following code:

for(int i = 1; i <= 10; i++) {

     for(int j = 0; j < (20 - i * 2) / 2; j++) {

          System.out.print(" ");

     }

     for(int j = 0; j < i * 2; j++) {

          System.out.print("*");

     }

     for(int j = 0; j < (20 - i * 2) / 2; j++) {

          System.out.print(" ");

     }

     System.out.println();

}

1.

Describe the output of the code above.

An arrow pointing upward, having a base 20 characters wide and a top that is 2 characters wide.

An arrow pointing upward, having a base 20 characters wide and a top that is 1 character wide.

An arrow pointing downward, having a base 20 characters wide and a top that is 2 characters wide.

A right-facing arrow with large base of 20 characters in size and a point that is 2 characters wide.

A left-facing arrow with a large base of 20 characters in size and a point that is 1 character wide.

1/2 questions

0%
Learning Tools by Varsity Tutors