My Solution: I am running this program in CodeBlocks. It is not working and it shows:
//error: array type has incomplete elements type 'int[]'
//warning: return type of 'main' is not 'int'
I want to function which calculates the sum of each row and their total. This solution doesn't work because it shows an error in function declaration.
//function declaration
void findSumEachRowAndTotalSum(int a[][], int c, int r){
int i, j, rowSum, totalSum;
//ask the user to give elements of rows
for(i=0; i<c; i++){
printf("\nGive elements of row %d:\n", i+1);
for(j=0; j<r; j++)
scanf("%d", &a[i][j]);
}
totalSum = 0;
for(i=0; i<c; i++){
rowSum = 0;
for(j=0; j<r; j++){
//calculates the sum of each row and total sums
rowSum = rowSum + a[i][j];
totalSum = totalSum + a[i][j];
}
//displays sum of each row on the screen
printf("\nSum of row %d is %d", i+1, rowSum);
}
//displays the total sum of all rows on the screen
printf("\nTotal sum is %d\n", totalSum);
}
//main function
void main(void){
int col, row, m[50][50], i, j;
//...
//function call
findSumEachRowAndTotalSum(a,c,r);
}