Complete the code to print numbers from 1 to 3 using a nested loop.
for (int i = 1; i <= 3; i++) { for (int j = 1; j <= [1]; j++) { Console.WriteLine(j); } }
The inner loop should run from 1 to 3 to print numbers 1, 2, and 3.
Complete the code to print a 3x3 grid of stars (*) using nested loops.
for (int row = 1; row <= 3; row++) { for (int col = 1; col <= [1]; col++) { Console.Write("*"); } Console.WriteLine(); }
The inner loop must run 3 times to print 3 stars per row.
Fix the error in the nested loops to correctly print pairs of numbers.
for (int x = 1; x <= 2; x++) { for (int y = 1; y <= [1]; y++) { Console.WriteLine($"({x}, {y})"); } }
The inner loop should run 2 times to print pairs (1,1), (1,2), (2,1), (2,2).
Fill both blanks to create a nested loop that prints a multiplication table for 1 to 3.
for (int i = 1; i <= [1]; i++) { for (int j = 1; j <= [2]; j++) { Console.Write($"{i * j} "); } Console.WriteLine(); }
Both loops should run from 1 to 3 to print a 3x3 multiplication table.
Fill all three blanks to create a nested loop that prints a right-angled triangle of stars.
for (int row = 1; row <= [1]; row++) { for (int col = 1; col <= [2]; col++) { if (col <= [3]) { Console.Write("*"); } } Console.WriteLine(); }
The outer and inner loops run 5 times. The if condition prints stars up to the current row number to form a triangle.