C Program to Find the Norm of a Matrix

C Program to Find the Norm of a Matrix : The norm is defined as the square root of the sum of squares of all elements in the matrix. Write your own code, please.

C Program to Find the Norm of a Matrix

#include <stdio.h>
  #define ROW 10
  #define COL 10
  int main() {
        int array[ROW][COL], norm[COL] = {0};
        int i, j, row, col, max;
        printf("Enter the number of rows:");
        scanf("%d", &row);
        printf("Enter the number of columns:");
        scanf("%d", &col);
        printf("Enter the entries for input matrix:\n");
        for (i = 0; i < row; i++) {
                for (j = 0; j < col; j++) {
                        scanf("%d", &array[i][j]);
                }
        }
        for (i = 0; i < col; i++) {
                for (j = 0; j < row; j++) {
                        norm[i] = norm[i] + array[j][i];
                }
        }

        max = norm[0];
        for (i = 0; i < col; i++) {
                if (max < norm[i]) {
                        max = norm[i];
                }
        }
        printf("Max(");
        for (i = 0; i < col; i++) {
                printf("%d ", norm[i]);
        }
        printf(")\n");

        printf("Norm of the given matrix is %d\n", max);
        return 0;
  }

Output of Program

Enter the number of rows:2
Enter the number of columns:3
Enter the entries for input matrix:
3
23
25
25
24
23
Max(28 47 48 )
Norm of the given matrix is 48