I've got the program body, most of my errors are in my function. I've tried fixing it but i can't change the data types.
#include <stdio.h>
int sumrow (int matrix);
int sumcol (int matrix);
int main () {
int matrix [3][4] = { {5, 7, 4, 8}, {6, 8, 2, 4}, {2, 7, 9, 6} };
int sum;
sumrow = matrix[3][4];
[Error] assignment of function 'int sumrow(int)' This data type error makes no sense to me and I can't change it. [Error] cannot convert 'int' to 'int(int)' in assignment
sumcol = matrix[3][4];
[Error] assignment of function 'int sumcol(int)' [Error] cannot convert 'int' to 'int(int)' in assignment The errors here are identical and I am probably calling the error incorrectly.
return 0;
}
int sumrow (int matrix){
int i, j, sum = 0;
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 3; ++j)
{
sum = sum + matrix[i][j] ;
[Error] invalid types 'int[int]' for array subscript Both functions have the same error and I think it's because of the variables i used.
}
}
return printf("Sum of the %d row is = %d\n", sum);
}
int sumcol (int matrix){
int i, j, sum = 0;
for (j = 0; j < 3; ++j)
{
for (i = 0; i < 4; ++i)
{
sum = sum + matrix[i][j];
[Error] invalid types 'int[int]' for array subscript I don't know how to fix this error.
}
}
return printf("Sum of the %d column is = %d\n", sum);
}
int sumcol (int matrix);andsumcol = matrix[3][4];: Issumcolsupposed to be a function or anint? Same question withint sumrow (int matrix);.sumrow = matrix[3][4];andsumcol = matrix[3][4];.int sumrow (int matrix)should beint sumrow (int matrix[3][4])and the call should besumrow(matrix)