#include <stdio.h>
int main(int argc, char const *argv[])
{
int n,m,t[n][m];
printf("\nEnter the dimensions of the array N x M: ");
scanf("%d %d",&n,&m);
printf("\nScanning the array:\n");
for (int i = 0;i<n;i++) {
for (int j = 0;j<n;j++) {
scanf("%d",&t[i][j]);
}
}
int sl;
for (int k=0;k<n;k=k+1) {
sl = 0;
for (int p=0;p<m;p++){
sl = sl + t[k][p];
}
printf("\nThe sum of the line number %d is %d",k+1,sl);
}
return 0;
}
and this is the out put of few tests :
#1:
Enter the dimensions of the array N x M: 3 3
Scanning the array:
5 6 7
8 9 10
1 1 1
The sum of the line number 1 is 3
The sum of the line number 2 is 3
The sum of the line number 3 is 3
#2 :
Enter the dimensions of the array N x M: 4 4
Scanning the array:
0 0 0 0
0 1 1 0
1 0 0 1
0 1 0 1
The sum of the line number 1 is 2
The sum of the line number 2 is 2
The sum of the line number 3 is 2
The sum of the line number 4 is 2
int n,m,t[n][m];you can't do that in C, you need to allocate the matrix dynamically