logo CodeStepByStep logo

nestedStarsOutput

Language/Type: Java expressions %

What output is produced by the following code?

for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= i; j++) {
        System.out.print("*");
    }
    for (int j = 1; j <= 20 - 2 * i; j++) {
        System.out.print(" ");
    }
    for (int j = 1; j <= i; j++) {
        System.out.print("*");
    }
    System.out.println();
}
output

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.