Its base and height are both equal to n. It is drawn using # symbols and spaces. The last line is not preceded by any spaces. We have to write a program that prints a staircase of size n.
Solution
Explanation:
Step 01: Iterate a for loop.
Step 02: While iterating the loop we need to print the blank spaces and the "#".
Step 03: While printing we need to repeat the blank spaces by n-i number and "#" by the i number of times so that from top to bottom, in each row the blank spaces reduce and the number of "#" increases and it turns into a staircase shape.
Top comments (0)