logo CodeStepByStep logo

loop_mystery_print1

Language/Type: C for nested loops

What does the following code print out?

for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= 10 - i; j++) {
        printf(" ");
    }
    for (int j = 1; j <= 2 * i - 1; j++) {
        printf("*");
    }
    printf("\n");
}
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.