Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to replace an element in array in c++

#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*/
 
PREVIOUS NEXT
Tagged: #replace #element #array
ADD COMMENT
Topic
Name
6+8 =