> How to check if the sums of each rows in 2d array are equal or not in a C program?

How to check if the sums of each rows in 2d array are equal or not in a C program?

Posted at: 2014-12-18 
I'm basically new to programming and I just want to know how to check if the sums of each rows in 2d array are equal or not in a C program.

/* sum the first row */

row1sum = 0;

for (j=0; j
/* verify each additional row sum: */

sum_match = 1;

for (i=1; i
{

.... int sum = 0;

.... for (j = 0; j
.... if (sum != rowsum) sums_match = 0;

}

/* sums_match is 1 if all row sums are the same, or 0 if not. */

To read the array and add row values, you need two nested for loops.

If all you want to know is whether any row totals are different, just compare each row total with the previous.

http://www.programiz.com/c-programming/c...

Thank you for the answer. :) I'll try to study more about C programming.

I'm basically new to programming and I just want to know how to check if the sums of each rows in 2d array are equal or not in a C program.