BEST代写-线上留学生作业代写 & 论文代写专家


C语言代写|Perimeter Of A Sequence Of Squares Programs

C语言代写|Perimeter Of A Sequence Of Squares Programs


For this coursework we want to create a very simple C program that takes a number as an input and returns the perimeter of a sequence of squares.

The rectangle is aranged as follows:


The image shows 8 squares with a side length of of 1, 1, 2, 3, 5, 8, 13 and 21 respectively. If we sum up the perimeters of these squares we get : 4 * (1 + 1 + 2 + 3 + 5 + 8 + 13 + 21) = 216


In perimeter.c write a function that takes an integer n and returns the sum of the perimeters of n+1 such squares.


Hint: You may want to have a look at the Fibonacci sequence.


  1. Add your name and CIS ID to this file.
  2. Write the function perimeter(int n) in perimeter.c (20 marks)
  3. Ensure that all tests in the tests folder run successfully. When you push to the project this will be automatically checked by githubs CI, if you see a small green checkmark next to your commit everything is fine, if not, click on the red x to see what has gone wrong. (5 marks)
  4. Write a Makefile for the project in Makefile (10 marks). For full marks the makefile should automate finding and linking files so that the addition of new files does not “break” the makefile. It should have the following options

– all: create an executable called perimeter that takes a number n as an input and returns the sum of the perimeters of n+1 squares

– clean: remove all executables

– test: manually run the tests in test

  1. Currently the tests could be passed by simply assigning the correct value to each of the 4 inputs. Add a test to tests/test.c that resolves this issue. (5 marks)
  2. Code is clean and easy to read and does not contain unneeded variables, etc., README has been edited (10 marks)