Starting from:

$34.99

comp2510 Lab 2 Solution

lab2.c skeleton file is created for you. Write a function that rotates an array. The signature of the function is:

void rotateArray(char *ptr, int n)

You would need to implement a function that rotates this array by an angle specified by the command line argument. Let’s assume a small example that is 4 x 4. The file contains the following contents.

>> cat input.txt
XXXX
XXXX
PPPP
PPPP

Here is the output of running the input file through your program.
>> ./rotate intput.txt 90
PPXX
PPXX
PPXX
PPXX

Detailed specifications are below.
1. The command line argument is in this order <executable> input_file angle
2. I am supplying with one input file, but you are supposed to come up with your own input file as well to test your code
3. Angle will be multiples of 90. The value can be positive, 0, or negative. Positive means clockwise rotation whereas negative means counter-clockwise rotation.
4. You will implement rotateArray function
5. Your implementation in rotateArray function should NOT include any printf statement
6. Your input array size is guaranteed to be 20 by 20. This will be the size of the arr in the file and the number of characters being passed by the input file
7. There will not be any corner case testing, meaning assume that the input file will always contain valid number of characters
8. Only alphanumeric characters and symbols on English keyboard will be used in the input file

Restrictions
• Do NOT modify main function at all
• Only use standard libraries listed in Learning Hub

Grading
• (1 point) Correctly use git/GitHub and the repository following the lab handout
• (2 point) Generate a correct solution to the problem(s) in this lab
• (2 point) Correctly format outputs

Submission Files
• You must deliver only one .c file named: lab2.c
• The file that you submit should be a .c file (not .txt, not .cpp or any other type)
• lab2.c (do not capitalize)
• AXXXX.txt (empty file, but with your A number as file name)
• In Github, there must be only lab2.c and AXXX.txt file. Nothing else, so make sure to remove all other files there.
• Github: https://classroom.github.com/a/6A7d09d-

More products