****
****
****
****
1)Require minimum 2 nested loop
2)Outer loop is for row
3)Inner loop is for column
4)Print in inner loop
Explanation:
1)The Pattern has 4 rows and each row contains 4 stars(*).
2)To print this pattern , we need two loops:
Outer loop for the rows
Inner loop for the columns(stars in each row).
3)In each iteration of the outer loop, the inner loop prints 4 stars.
//You can adjust the value of rows to generate more or fewer lines of the pattern. |
Java |
public class Pattern { public static void main(String[] args) { // Number of rows in the pattern int rows = 3; // Outer loop for rows for (int i = 0; i < rows; i++) { // Inner loop for columns for (int j=0;j<rows;j++) { System.out.print(“*”); } // Move to the next line System.out.println(); } } } |
C++ |
|
Python |
rows = 4 # number of rows # Outer loop for rows for i in range(rows): # Inner loop for columns for j in range(rows): print("*", end="") # Print stars in the same line print() # Move to the next line after printing a row |