#include using namespace std; void print_array(int arr[], int length){ cout << "["; for(int i = 0; i < length; i++) cout << arr[i] << ", "; cout << "\b\b]\n"; } int main(){ int arr[] = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}; int array_length = sizeof(arr)/sizeof(int); // This does give us the length cout << "Our array takes up " << sizeof(arr) << " bytes\n"; print_array(arr, array_length); // calculate average value double sum = 0; for(int n : arr) sum += n; double average = sum / 10; cout << "The average in our array is " << average << endl; // Let's delete an item int index_to_delete = 2; array_length--; for(int i = index_to_delete; i < array_length; i++) arr[i] = arr[i+1]; print_array(arr, array_length); // Let's add a 60 where the 6 was // We have a fixed amount of space, but it'll fit int index_to_insert = 2; for(int i = array_length; i >= index_to_insert; i--) arr[i+1] = arr[i]; arr[index_to_insert] = 60; array_length++; print_array(arr, array_length); return 0; }