PROGRAM TO COPY ELEMENTS OF AN ARRAY INTO ANOTHER ARRAY

/*PROGRAM TO COPY ELEMENTS OF AN ARRAY INTO ANOTHER ARRAY*/

#include<conio.h>

#include<iostream.h>

class copy_array

{

int m,n,i,j,a[10][10],b[10][10];

public:

void input();

void output();

};

void copy_array::input()

{

cout<<“Enter order of the matrix: “;

cin>>m>>n;

cout<<“Enter “<<m*n<<” elements into array: \n”;

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

cin>>a[i][j];

}

};

void copy_array::output()

{

cout<<“Entered elements of given array are:\n”;

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

cout<<a[i][j]<<”   “;

cout<<endl;

}

cout<<“After copying elements of second array are:\n”;

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

b[i][j]=a[i][j];

cout<<b[i][j]<<”    “;

}

cout<<endl;

}

}

void main()

{

copy_array  c1;

clrscr();

c1.input();

c1.output();

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *