This C Program find the trace & normal of a given matrix. Here trace of the matrix is the sum of the elements of the main diagonal i.e the diagonal from the upper left to the lower right of a matrix. Normal of the matrix is the square root of the sum of all the elements.

Here is source code of the C program to find the trace & normal of a given matrix. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C program to find the trace and normal of a matrix`

`*`

`* Trace is defined as the sum of main diagonal elements and`

`* Normal is defined as square root of the sum of all the elements`

`*/`

`#include <stdio.h>`

`#include <math.h>`

void main ()

`{`

static int array[10][10];

int i, j, m, n, sum = 0, sum1 = 0, a = 0, normal;

printf("Enter the order of the matrix\n");

scanf("%d %d", &m, &n);

printf("Enter the n coefficients of the matrix \n");

for (i = 0; i < m; ++i)

`{`

for (j = 0; j < n; ++j)

`{`

scanf("%d", &array[i][j]);

a = array[i][j] * array[i][j];

sum1 = sum1 + a;

`}`

`}`

normal = sqrt(sum1);

printf("The normal of the given matrix is = %d\n", normal);

for (i = 0; i < m; ++i)

`{`

sum = sum + array[i][i];

`}`

printf("Trace of the matrix is = %d\n", sum);

`}`

$ cc pgm84.c -lm $ a.out Enter the order of the matrix 3 3 Enter the ncoefficients of the matrix 3 7 9 2 6 10 8 5 9 The normal of the given matrix is = 21 Trace of the matrix is = 18

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Matrix, go to C Programming Examples on Matrix. If you wish to look at programming examples on all topics, go to C Programming Examples.