Answers for "how to replace an element in array in c++"

C++
0

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*/
Posted by: Guest on August-11-2020

Code answers related to "how to replace an element in array in c++"

Browse Popular Code Answers by Language