For this assignment you will write two programs, both of which begin by asking the user for the dimensions of a 2d (multi-dimensional) array, then asking the user to enter that many integers, and then placing the values the user enters into the 2d array.
The basic process is the same as we did for regular arrays, but requires the use of nested looping. See 2darray.c in the GitHub code example repo for a demonstration.
In the file transpose.c
, write a program that prints out the transpose of a matrix that is entered as input by the user. Implementation details are provided in the transpose.c
file as a comment.
In the file blur.c
, write a program that applies an image blurring algorithm to an input 2d array representing pixel data for an “image”. While you will not actaully be able to view the image, the output “image” is a grid of numbers representing the blur values for each “pixel” in the range 0 to 255.
I HIGHLY recommend using the make file commands below to run tests with input to save yourself a bunch of repeated typing. After all, computer are great a repitious task, so take advantage of that! :)
You can run tests for each of the programs using the following commands respectively:
make gh-test-transpose
make gh-test-blur
If the tests don’t pass or there are compiler errors, review the output and then re-run the tests above until you are passing the testing locally.
When you are confident your programs function correctly submit your work by saving your code and then using git to add the C files, commit, and pushing your changes. You can add all the files on one line if you want, like this:
git add blur.c transpose.c
git commit -m "This is an example commit message"
git push
You can also add them one at a time (with four individual git add commands). You don’t need to push after each commit, so if you add the files separately, you only need ONE push.
Once you have pushed, check GitHub to see the results of testing your code. If any of your programs do not pass the tests, you may make changes and submit again. To submit again, simply add the file(s) that you changed, commit, and push again.
For full credit all the tests must pass
Your grade for this exercise will be out out of 10 points:
transpose.c
blur.c