array Value Replacement in c++ in a specific place

Array value replacement in C++ Program  in a specific array location     

The initialization of array starts from arr [0]................arr[n-1], Here we are replacing arr[2], hence the third element will be replaced. 

#include <iostream>

using namespace std;
int main()
{
int arr[10]={10,20,30,40,15};

cout<<"Enter the arr[10]"<<endl;
int a;
cin>>a;
arr[2] = a;

for(int i=0;i<5;i++){
    cout<<arr[i]<<" ";
}
    return 0;
}



Previous Post
Next Post
Related Posts

0 Comments: