// Demonstrating your first arrays // Program tracks my crazy parcel delivery over a course of the week in lockdown // Sasha Vassar Week 3, Lecture 6 // Problem: I want to track the number of parcels that I have received over a // particular week during lockdown. If the number of parcels is greater than 2 // in any given day, than I may have been too extreme, so I want to be told to // slow down on the purchases. // 1. How can I solve this problem now with the last two weeks of knowledge only? // a. Using just variables // 2. Can you see that this is very messy and not efficient? Let's learn a better way // to solve these types of problems #include #define N_DAYS 7 int main (void) { // DEclare an array & Initialise it int parcel_week[N_DAYS]; // Initialise the array by scanning in user input int i = 0; while (i < N_DAYS) { printf("How many parcels did you receive on day %d: ", i); scanf("%d", &parcel_week[i]); i++; } // i = 7 // Print out the different elements of the array i = 0; while (i < N_DAYS) { printf("%d\n", parcel_week[i]); i++; // i = i + 1 } return 0; }