HOME

Tuesday, January 17, 2017

C++ PROGRAM TO FIND SUM OF ROW AND COLUMN IN MATRIX FORM

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a[3][3],i,j,c1,c2;
cout<<"Enter 3*3 matrix"<<endl;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
    cin>>a[i][j];
    cout<<"    ";
}
cout<<endl;
}
for(i=0;i<3;i++)
{
    c1=0;
for(j=0;j<3;j++)
{
    cout<<a[i][j]<<"    ";
    c1+=a[i][j];
}
cout<<c1;
cout<<endl;
}
for(i=0;i<3;i++)
{
    c2=0;
for(j=0;j<3;j++)
{
c2+=a[j][i];
}
cout<<c2<<"    ";
}
return 0;
}

No comments:

Post a Comment