1. Write a C Program to find the sum of all elements of each row of a matrix.
Sample Input:
Enter the number of rows and columns of the matrix: 3 3
Enter the elements of the matrix:
Enter element [0][0]: 1
Enter element [0][1]: 2
Enter element [0][2]: 3
Enter element [1][0]: 4
Enter element [1][1]: 5
Enter element [1][2]: 1
Enter element [2][0]: 1
Enter element [2][1]: 2
Enter element [2][2]: 3
Output:
Matrix:
123
451
123
Sum of each row:
Sum of row 1 = 6
Sum of row 2 = 10
Sum of row 3 = 6
2. Write a C Program to print upper diagonal of a matrix and user will give input.
Sample Input:
Enter the number of rows and columns of the matrix: 3 3
Enter the elements of the matrix:
Enter element [0][0]: 1
Enter element [0][1]: 2
Enter element [0][2]: 3
Enter element [1][0]: 4
Enter element [1][1]: 5
Enter element [1][2]: 6
Enter element [2][0]: 7
Enter element [2][1]: 8
Enter element [2][2]: 9
Output:
Upper Diagonal Elements of the Matrix:
123
56
9
3. Write a C program to find the sum of the diagonal elements.
Sample input:
Enter the number of rows and columns of the matrix: 3 3
Enter the elements of the matrix:
Enter element [0][0]: 1
Enter element [0][1]: 2
Enter element [0][2]: 3
Enter element [1][0]: 4
Enter element [1][1]: 5
Enter element [1][2]: 6
Enter element [2][0]: 7
Enter element [2][1]: 8
Enter element [2][2]: 9
Matrix:
1 2 3
4 5 6
7 8 9
Output:
Diagonal elements: 1 5 9
Sum of diagonal elements: 15
4. Write a C program to transpose a matrix.
Sample Input:
Enter the number of rows and columns of the matrix: 2 2
Enter the elements of the matrix:
Enter element [0][0]: 1
Enter element [0][1]: 2
Enter element [1][0]: 3
Enter element [1][1]: 4
Original Matrix:
12
34
Output:
Transposed Matrix:
13
24