Boxes

This is a challenge exercise. It is not compulsory, and may be completed individually or with your lab partner.

For this challenge, make a program called boxes.c which reads in a number and then draws that many square boxes inside each other using the character #.

For example:

How many boxes: 1
###
# #
###
How many boxes: 2
#######
#     #
# ### #
# # # #
# ### #
#     #
#######
How many boxes: 5
###################
#                 #
# ############### #
# #             # #
# # ########### # #
# # #         # # #
# # # ####### # # #
# # # #     # # # #
# # # # ### # # # #
# # # # # # # # # #
# # # # ### # # # #
# # # #     # # # #
# # # ####### # # #
# # #         # # #
# # ########### # #
# #             # #
# ############### #
#                 #
###################

To run some simple automated tests:

$ 1511 autotest boxes

To run Styl-o-matic:

$ 1511 stylomatic boxes.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk04_boxes

Or, if you are working from home, upload the relevant file(s) to the wk04_boxes activity on Give Online.