matrix array

hi, im trying to write a program that sum each row of an array and prints it out along with the total sum of the array. heres what i have done so far


#include<iostream>

using namespace std;

int main()

{
int iMatrix[4][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
int sum = 0;

for (int x=0; x<4; x++)
{
for (int y = 0; y<4; y++)
{
sum+=iMatrix[x][y] ;

}
cout << sum << " \t ";

cout << endl;
}

return 0;
}
Topic archived. No new replies allowed.