Spirals

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 spirals.c which reads in a number and then draws that many rectangular spirals inside each other using the character #. You may want to start by modifying the code you used in boxes.c.

For example:

Enter the spiral size: 1
####
#  #
## #
Enter the spiral size: 2
########
#      #
# #### #
# #  # #
# ## # #
#    # #
###### #
Enter the spiral size: 5
####################
#                  #
# ################ #
# #              # #
# # ############ # #
# # #          # # #
# # # ######## # # #
# # # #      # # # #
# # # # #### # # # #
# # # # #  # # # # #
# # # # ## # # # # #
# # # #    # # # # #
# # # ###### # # # #
# # #        # # # #
# # ########## # # #
# #            # # #
# ############## # #
#                # #
################## #

To run some simple automated tests:

$ 1511 autotest spirals

To run Styl-o-matic:

$ 1511 stylomatic spirals.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_spirals

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