Check out example codes for "how to replace an element in array in c++". It will help you in understanding the concepts better.

Code Example 1

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int arr[3] = {0,1,2};
	cout << "Before update "<<arr[2]<<endl;
	arr[2]=1;//updating element
	cout <<"After update "<<arr[2]<<endl;
}

/*output:-
Before update 2
After update 1*/

Learn ReactJs, React Native from akashmittal.com