copy one array into another in C++ by R4R Team

Array:
Array is the collection of different values having same data type.
-We have a integer Array that having all integer values.
-Character array is known as String.


program:


#include < iostream>
using namespace std;
int main()
{
int a[20],b[20],i,n;
cout<<"Number of element in array?"<< endl;
cin>>n;
cout<<"Enter element in array"<< endl;
//input in first array
for(i=0;i< n;i++){
cin>>a[i];
}
//copy one array into another array
for(i=0;i< n;i++){
b[i]=a[i];
}
//Now display second array
cout<<"Array is: "<< endl;
for(i=0;i< n;i++)
{
cout<< b[i]<<" ";
}
return 0;
}


output-

Number of element in array?
5
Enter element in array
4 7 2 9 4
Array is:
4 7 2 9 4




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!