#include <iostream>
usingnamespace std;
int main()
{
int array2[15], i, j ,n,s;
cout<<"Enter the number of rows and columns for the matrix" <<endl;
cin>>n;
int array[n][n];
for(i=0;i<n;i++)
{
for(j=0; j<n; j++)
{
cout<<"Enter the elements of the matrix" <<endl;
cin>>array[n][n];
}
}
s=0;
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
s=s+array[i][j];
cout <<"The sum of the elements on the " <<i << "row is:" <<s<<endl;
s=0;
}
}
return 0;
Hey, MiiNiPaa thanks for the help. I did fix that but also had some other problems so I worked on them and here's the working solution if anyone else needs help with this:
#include <iostream>
usingnamespace std;
int main()
{
int array2[15], i, j ,n,s;
cout<<"Enter the number of rows and columns for the matrix" <<endl;
cin>>n;
int array[n][n];
for(i=0;i<n;i++)
{
for(j=0; j<n; j++)
{
cout<<"Enter the elements of the matrix" <<endl;
cin>>array[i][j];
}
}
int br=0;
for(i=0; i<n; i++)
{
br++;
s=0;
for(j=0; j<n; j++)
{
s=s+array[i][j];
}
cout <<"The sum of the elements on the " <<br<< "row is:" <<s<<endl;
}
return 0;
}