The program adds 2 matrices that are 3x3 using arrays and then stores them into another matrix (array) and then it's edited to show a diagonal line of "0" through it, btw I'm pretty new to programming and this is my first prog.language to learn.
insert
Code:
#include <iostream>
using namespace std;
int main()
{
int x[3][3],y[3][3],c[3][3],i,j;
cout<<"Enter your numbers"<<endl;
for(i=0;i<=2;i++) // Entry stage
for(j=0;j<=2;j++)
{
cin>>x[i][j];
cin>>y[i][j];
}
for(i=0;i<=2;i++) //Addition stage
for(j=0;j<=2;j++)
c[i][j]=y[i][j]+x[i][j];
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
{
if(i=j)
c[i][j]=0;
}
for(i=0;i<=2;i++) // Plotting the zero line and displaying the result
{
cout<<endl;
for(j=0;j<=2;j++)
cout<<c[i][j]<<" ";
}
return 0;
}
It works almost just fine lol, Except that the first portion of the diagonal line does not become zero and instead displays the normal addition result :/, please ,i would be grateful for any help.