Outputting a * triangle
Hey I am new to forums, so if I don't put something in the post please tell me. I am trying to out put a "*" triangle from a user input of the height and base, but not just a regular right triangle. If the user put in a height of 3 and a base of 5 it should look like this
i just cant figure out the algorithm to use in a for loop. This is what I have for the for loop so far
for(int i=0; i < triHeight;i++)
for(int j = 1; j<=triBase; j++)
with triHeight and triBase being ints entered by the user. This prints out a square. I was told that the j increment should have something to do with the base and the height but i am really lost.
Firstly, welcome to the forums.
The problem you are having relates to the second for loop. As the value of 'triBase' never changes between loops, the output for each repetition is always going to be the same.
I'm not going to give you the code straight off, that would be too easy. Instead I can point you in the right direction.
As already mentioned, the value in the second for loop needs to change between repetitions. But what value should this take?
Just to get you started, divide 'triBase' by 'triHeight' this give you the increment per line.
If you're still stuck then post back.