Right-Angled Triangle With Asterisks Algorithm
1 min readMay 25, 2023
ALGORITHM:
- Get the input
n
, which represents the number of rows and columns for the triangle. - Initialize two loops:
- The outer loop with variable
i
starts from 0 and continues untili < n
. - The inner loop with variable
j
starts from 0 and continues untilj < n
3. Within the inner loop, perform the following steps:
- Print an asterisk (
*
) to create the visual pattern of the triangle. - Increment
j
by 1 to move to the next column.
4. After the inner loop completes, create a new line to move to the next row.
5. Increment i
by 1 to move to the next row in the outer loop.
6. Repeat the above steps until the outer loop condition (i < n
) is satisfied.
7. The algorithm will create a right-angled triangle pattern with n
rows and n
columns, where each position in the triangle is filled with an asterisk (*
).
FLOWCHART: