A homework question was posted on a forum recently. As usual it was met with the cries of “We won’t do your homework for you” (We will, of course, help if you get stuck. But don’t expect any assistance without at least trying first)
The assignment was to write a console application that accepted a width and a height from the user and then created a rectangle using asterisks. e.g. This might be the result of the program
Width:8 Height:5 ******** * * * * * * ********
Now the query was asked how to complete this using loops (or conditional statements, we weren’t really sure – he said loops, but proceeded to talk about if/else statements)
One of the responses was along the lines of “I can do this without loops”, modified to add “Or conditional statements”, and modified again to add “Or recursion”
So, my challenge to you is to write a small program above without loops, conditional statements or recursion. It sounds difficult, but it isn’t really. I have a solution (from which the example output above has been taken) which I’ll post this evening.