C++ program to copy all elements of one array to another
Write a C++ program to copy all elements of one array to another?
Write a C++ program to input the values in an array and copy all elements of the first array into the second array.
How to copy array elements to another array in C++. Logic to copy array elements from one array to another array.
Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include<iostream> using namespace std; int main() { int p,n,i[100],j[100]; cout<<"Please enter the size of array :"<<endl; cin>>n; cout<<"Please enter the 1ST array elements :"<<endl; for(p=0;p<n;p++) { cin>>i[p]; } cout<<"elements of 1st array :"<<endl; for(p =0;p<n;p++) { cout<<i[p]<<" "; } for(p=0;p<n;p++) { j[p]=i[p]; } cout<<endl<<"element 2nd array :"<<endl; for(p=0;p<n;p++) { cout<<j[p]<<" "; } } |
Output