Here are some suggestions.
Code:
#include <stdio.h>
#define a 5
int main()
{
int row, col/*, rt=0, ct=0, x=0 */;
long int rt,ct,number[a][a]/* = {1}, num=0 */;
for (row=0; row<a; row++) {
printf("Enter row %d:", row+1 /* ++x */);
fflush(stdout);
for (col=0; col<a; col++)
scanf("%ld", &number[row][col]);
}
printf("\nRow totals:\n");
for ( row=0; row<a; row++) {
for (rt=0, col=0; col<a; col++) {
rt += /* =+ */ number[row][col];
}
printf("Row %d: %ld\n", row + 1, rt);
}
printf("\nColumn totals:\n");
for (col=0; col<a; col++) {
for (ct=0, row=0; row<a; row++) {
ct += /* =+ */ number[row][col];
}
printf("Column %d: %ld\n", col + 1, ct);
}
printf("\n\n");
return 0;
}
Sample execution:
Code:
Enter row 1: 1 2 3 4 5
Enter row 2: 2 3 4 5 6
Enter row 3: 3 4 5 6 7
Enter row 4: 4 5 6 7 8
Enter row 5: 5 6 7 8 9
Row totals:
Row 1: 15
Row 2: 20
Row 3: 25
Row 4: 30
Row 5: 35
Column totals:
Column 1: 15
Column 2: 20
Column 3: 25
Column 4: 30
Column 5: 35