I am trying to create a rectangle using only one for loop but I am not sure how to go about this. The user is to enter a width and height and the output is a rectangle but in my code I can only use ONE for loop. How can this be done?
Keep a counter with the current line length and insert a newline when appropriate.
Either that or use the modulo operator to check when you need to change lines.
Thank you for your response. If I keep a counter with the line length, how do I know when to insert a newline without a nested for loop. Sorry, I am new at this and I just can't figure this out at all.
My assignment says I can use only one FOR loop and nothing about while loops. It also says as a hint to multiply the height and width to get total number of characters in the rectangle. I figure since I am so new and this is a beginner class that I should get credit for this way. But just in case, how would you write the output?