C Program to Find the Normal and Trace - Source Code, Output & Execution Flow

C Program to Find the Normal and Trace

This tutorial explains c program to find the normal and trace with C source code, sample output, and step-by-step execution flow.

#include <stdio.h>
#include <math.h>
int main() {
    int a[2][2] = {{1, 2}, {3, 4}}, i, j, trace = 0, sum = 0;
    for (i = 0; i < 2; i++) {
        trace += a[i][i];
        for (j = 0; j < 2; j++) sum += a[i][j] * a[i][j];
    }
    printf("Trace = %d
Normal = %.2f
", trace, sqrt(sum));
    return 0;
}
Trace = 5
Normal = 5.48

In this program, the input is read first when required, the core logic is applied step by step, and the final result is displayed using printf(). Follow the execution flow beside the code to understand how each statement contributes to the output.