Saturday, 28 June 2014

C++ program to copy one matrix to another


Here is a C++ program to copy one matrix to another


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    int a[10][10],b[10][10],row,col;
    cout<<"Enter row and column of matrix (max 10*10): ";
    cin>>row>>col;
    cout<<"Enter matrix a1 : "<<endl;
    for(int i=0;i<row;i++)
        for(int j=0;j<col;j++)
           cin>>a[i][j];
    for(int i=0;i<row;i++)
        for(int j=0;j<col;j++)
            b[i][j]=a[i][j];
    cout<<"Copy of matrix a1 : "<<endl;
    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
            cout<<b[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment