Monday, July 2, 2018

C program to check if given matrix is a upper triangle

// Function to check matrix is in upper triangular
// form or not.
#include<stdio.h>
int N,N;
int isUpperTriangularMatrix(int mat[N][N])
{
    for (int i = 1; i < N; i++)
        for (int j = 0; j < i; j++)
            if (mat[i][j] != 0)
                return 0;
    return 1;
}

// Driver function.
int main()
{
    int N=N=4;
    int mat[4][4] = { { 1, 3, 5, 3 },
                      { 0, 4, 6, 2 },
                      { 0, 0, 2, 5 },
                      { 0, 0, 0, 6 } };
    if (isUpperTriangularMatrix(mat))
        printf( "Yes");
    else
        printf("No");
    return 0;
}

No comments:

Post a Comment

The depression in freezing point of water observed for the same amount of acetic acid, trichloroacetic acid and trifluoroacetic acid increases in the order given above. Explain briefly.

  Depression in freezing point is a colligative property that depends on the number of solute particles in a solution. Since the order of de...