#include <iostream>
using namespace std;

// Write your code here
int& get_element(int arr[10], 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);     // do not remove this line

    get_element(arr, index) = value;

    for(int i = 0; i < 10; i++) {
        cout << arr[i] << (i == 9 ? "" : " ");
    }

    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

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