#include <iostream>
using namespace std;
// Provides direct access to an array element
int& get_element(int arr[], int index) {
return arr[index];
}
int main() {
int arr[10];
for(int i = 0; i < 10; i++) {
cin >> arr[i];
}
int index, value;
cin >> index >> value;
&get_element(arr, index); // valid only if an lvalue is returned
get_element(arr, index) = value;
for(int i = 0; i < 10; i++) {
cout << arr[i] << (i == 9 ? "" : " ");
}
return 0;
}Explanation & Logic Summary:
get_element returns access to an existing array elementFirmware Relevance & Real-World Context:
Input
1 2 3 4 5 6 7 8 9 10 3 99
Expected Output
1 2 3 99 5 6 7 8 9 10