logo CodeStepByStep logo

LoopMysteryPrint1

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++)
    {
        Console.Write(" ");
    }
    for (int j = 1; j <= 2 * i - 1; j++)
    {
        Console.Write("*");
    }
    Console.WriteLine();
}
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.