P
pillip
I am using data stored in a 20-20 array to find the mean of the rows and
columns, the results being stored in two other arrays. My problem is that
printf just gives the result for the first row and doesnt increment i. In
addition the integer j does not increment in printf either. (i, j being the
number of rows and columns respectively). Here is part of the code:
for (j=0; j<column; j++) {
sumrows=0;
for (i=0; i<rows; i++) {
sumrows += ara[j];
}
for (i=0; i<rows; i++) {
sumcolumn=0;
sum=0;
for (j=0; j<column; j++) {
sum += ara[j]*j;
sumcolumn += ara[j];
}
meanc[column] = sum/sumcolumn;
meanr[rows] = sumrows/rows;
printf("%d\t %13.10f\t %d\t %13.10f\n", i, meanrows[rows], j,
meancolumn[column]);
}
}
columns, the results being stored in two other arrays. My problem is that
printf just gives the result for the first row and doesnt increment i. In
addition the integer j does not increment in printf either. (i, j being the
number of rows and columns respectively). Here is part of the code:
for (j=0; j<column; j++) {
sumrows=0;
for (i=0; i<rows; i++) {
sumrows += ara[j];
}
for (i=0; i<rows; i++) {
sumcolumn=0;
sum=0;
for (j=0; j<column; j++) {
sum += ara[j]*j;
sumcolumn += ara[j];
}
meanc[column] = sum/sumcolumn;
meanr[rows] = sumrows/rows;
printf("%d\t %13.10f\t %d\t %13.10f\n", i, meanrows[rows], j,
meancolumn[column]);
}
}