What you have "tried" just prints a row of hyphens. You've been told that you need to use nested loops, so think about how you would do this manually. A number 2<=n<=7 is entered. In the first row, you need to draw a single box, but three lines of output are needed to create a box:
-
| |
-
The
nth row will contain
n boxes, and each row requires 3 lines of output. The first and last of those 3 lines will contain hyphens. The middle row will contain vertical bars with gaps.
Based on this, take a shot at writing the code.
EDIT#1: If this is going to be a true isosceles triangle, the first row must be indented so its box is centered. Only the last row won't be indented.
EDIT#2: To clarify, the output for three boxes should probably look like this:
-
| |
-
- -
| | | |
- -
- - -
| | | | | |
- - -
or even this in standard ASCII art :)
+-+
| |
+-+
+-+ +-+
| | | |
+-+ +-+
+-+ +-+ +-+
| | | | | |
+-+ +-+ +-+