// Week 3 Thursday Lecture // Demonstration of arrays // #include #define DAYS_IN_WEEK 7 int main(void) { int chocolate_eating[DAYS_IN_WEEK] = {4, 2, 5, 2, 0, 3, 1}; // How do we print the element at index 1 and what will that print? printf("%d\n", chocolate_eating[1]); // What if we print element at index 7? //printf("%d\n", chocolate_eating[7]); // How can I get the sum of the first and last element int sum = chocolate_eating[0] + chocolate_eating[DAYS_IN_WEEK-1]; printf("sum is %d\n", sum); // How can I modify the middle element and make it 99? chocolate_eating[DAYS_IN_WEEK/2] = 99; // How can I print out all data? (check bounds) int i = 0; while (i < DAYS_IN_WEEK) { printf("%d ",chocolate_eating[i]); i++; } printf("\n"); printf("Enter a number:\n"); // How can I read in a number from a user to store as // the second last element? scanf("%d", &chocolate_eating[DAYS_IN_WEEK-2]); // How can I print out all data? (check bounds) i = 0; while (i < DAYS_IN_WEEK) { printf("%d ",chocolate_eating[i]); i++; } printf("\n"); return 0; }