Algorithm To Print A Square Pattern
May 25, 2023
ALGORITHM:
- Get the input n, which is the number of rows and columns in the pattern.
- Initialize two loops, one for columns and one for rows.
- Set the variable i to 0 and repeat until i < n.
- Set the variable j to 0 and repeat until j < n.
- Within the inner loop, print a star symbol.
- Increment j by 1 to move to the next column.
- After the inner loop completes, create a new line to move to the next row.
- Increment i by 1 to move to the next row.
- Once both loops complete, the square pattern of stars will be printed.
CONCLUSION:
In conclusion, the algorithm to print a square pattern of stars is a straightforward process that involves using two nested loops to iterate over the rows and columns of the pattern.
FLOWCHART: