I need to make a program that asks the user the number of lines the pinetree will have then it should make a pinetree using the correspondent amount. It needs to be with one star in nested loops.
Example1:
Enter the amount of lines: 3
*
* *
* * *
Example2:
Enter the amount of lines: 5
*
* *
* * *
* * * *
* * * * *
Thanks in advance. Much is appreciated.
PS The pinetree is suppose to be like an actual tree when I post this the stars will all be on the left margin all together.
Get yourself a piece of graphing paper. Draw a thick vertical line down the left side. This represents the left edge of your terminal. Draw your stars. It might look something like:
Now you can count how many spaces you need and how many stars you need for each row.
You should recognize a pattern. This will help you write your loop.
When I created this kind of program,I used 3 loops,1 for horizontal asterisk creation and 1 for spaces,and my main loop. As you can see Duoas illustration you can't use even numbers for printing asterisk. To make it look like a pine tree use decrement when printing the spaces and increment for the asterisk.