Hi, english is not my mother tongue so bear with me please.
I have an assignment where we're going to write a program with the following effect:
Enter lines: 2
*
**
Enter lines: 4
*
**
***
****
...and so on.
I can't really figure out how to do this though. I'm guessing I should use a another loop inside a for loop, but I don't know how to implement it without making the nestled one infinite.
One way I could think of is storing the *'s in a string and print that, but that feels somewhat "ugly".
I'd obviously ask my teacher if possible, but since it's a distance class he's been hard to get hold of and I'd really like to figure this out before the weekend.
I also don't want a complete solution, just some hints.
Thank you, I got it now. I figured I might as well show what I wrote in case anyone would want to point out something I'm doing wrong, or for others to learn from (even if it was indeed a simple task :P).
You could also start with a string initialized to "*", perform the outer loop, and append the string to itself each time; although, I don't think this is what the teacher would be after...
EDIT: Scratch that idea; I was thinking of the similar assignment where each line of asterisks doubles in length.
ANOTHER EDIT: You could still start with an empty string and append a single "*" each time.