This homework aims to provide you with additional practice writing loops in C.
You may work with a partner for this assignment if you adhere to the guidelines.
Specification
For this homework, you should first complete the six exercises in the C loop lab. Add to those the two additional functions described below, with appropriate tests written by you. Don't forget to free the memory of any arrays created during your tests!
/* * Problem 7 * determine whether an array is a palindrome * that is, the function should return 1 if the array is a mirror * of itself, and 0 otherwise */ int palindrome(int* arr, int len) { // WRITE THIS } /* * Problem 8 * return a copy of the array that includes all elements * between positions m to n, including m but not n * you may assume that the array has at least n elements * * For example, if the array contains 0, 1, 2, 3, 4 * and you call sub with m = 2 and n = 4, * it should return a new array containing 2 and 3. */ int* sub(int* a, int m, int n) { // WRITE THIS }
You can copy the file from the lab using a Unix command at the command line. Alternately, you can start a new file and use copy/paste to transfer function definitions into it.
To Submit
- hw-loops.c containing all your functions, with tests written in main.
- readme.txt containing your self-reflection on this assignment