
December 10th, 2012, 10:42 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 1
Time spent in forums: 6 m 36 sec
Reputation Power: 0
|
|
|
Memory & arrays - Sum of row of 2D array
To find the sum of row of a 2D array ( 4 X 4 matrix)i've inserted the formula in function count and the values are sent to function printout via reference variable. The problem is only the sum of the last row is printed out.Help please? Thanks
void count( double L[][size],int n,double &rowTotal)
{
for (int i = 0; i < 4; i++)
{
rowTotal = 0;
for (int j = 0; j < 4; j++)
rowTotal += L[i][j];
}
void print_out(double totalRow,int n)
{
for(i=0;i<4;i++)
cout<< " Sum of row " << (i+1) << " = " << totalRow << endl;
}
|