Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define size 4
- void main()
- {
- int arr[size][size], row, col, sum = 0 ,sum2 = 0;
- printf("Give me 16 Numbers tfadal : \n");
- for (row = 0; row < size; row++)
- {
- for (col = 0; col < size; col++)
- {
- scanf_s("%d", &arr[row][col]);
- }
- }
- for (row = 0; row < size; row++)
- {
- sum = 0;
- for (col = 0; col < size; col++)
- {
- sum+= arr[row][col];
- }
- printf("\nThe Sum of Elements of Rows in a Matrix = %d", sum);
- }
- printf("\n");
- for (row = 0; row < size; row++)
- {
- sum2 = 0;
- for (col = 0; col < size; col++)
- {
- sum2 += arr[col][row];
- }
- printf("Sum of elements of column %d = %d\n", row + 1, sum2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement