// Week 4 Lecture recap example // Using arrays with functions #include #define DATA_SIZE 6 // print_data // read_data // print odd data // find_maximum void print_data(int size, int data[size]); void print_odd_data(int size, int data[size]); void read_data(int size, int data[size]); int find_maximum(int size, int data[size]); int main(void) { int data[DATA_SIZE] = {4, 6, 7, -3, 9, 2}; print_data(DATA_SIZE, data); //read_data(DATA_SIZE, data); //print_data(DATA_SIZE, data); print_odd_data(DATA_SIZE, data); int max = find_maximum(DATA_SIZE, data); printf("The max was %d\n", max); return 0; } void print_data(int size, int data[size]) { int i = 0; while (i < size) { printf("%d ", data[i]); i++; } printf("\n"); } void read_data(int size, int data[size]) { int i = 0; while (i < size) { scanf("%d", &data[i]); i++; } } void print_odd_data(int size, int data[size]) { int i = 0; while (i < size) { if(data[i]%2 != 0) { printf("%d ", data[i]); } i++; } printf("\n"); } int find_maximum(int size, int data[size]) { int max = data[0]; int i = 1; while (i < size) { if (data[i] > max) { max = data[i]; } i++; } return max; }