This program is a C program that checks whether a given matrix is a lower triangular matrix or not. It starts by taking user input for the number of rows and columns of the matrix using the scanf function. Then it takes the values of the matrix using a nested loop and another scanf function. It then uses another nested loop to iterate through the matrix and checks the elements of the matrix that are in the lower triangular section (elements below the main diagonal) and counts the number of zero elements in that section and stores it in the variable "z".
It also counts the number of elements in the upper triangular section of the matrix and stores it in the variable "o". It then checks if the total number of elements in the matrix is equal to the sum of zero elements in the lower triangular section and the number of elements in the upper triangular section. If the condition is true, it means that all the elements in the lower triangular section are zero, so the matrix is a lower triangular matrix, and it prints that it is a lower triangular matrix. Otherwise, it means that the matrix is not a lower triangular matrix, and it prints that it is not a lower triangular matrix.
#include<stdio.h> int main() { int a[10][10],i,j,r,c,z=0,o=0; printf("\nEnter the No of Rows:"); scanf("%d",&r); printf("\nEnter the No of Columns:"); scanf("%d",&c); printf("\nEnter the matrix Values:"); for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf("%d",&a[i][j]); } } for(i=0;i<r;i++) { for(j=0;j<c;j++) { printf("\t%d",a[i][j]); } printf("\n"); } for(i=0;i<r;i++) { for(j=0;j<c;j++) { if(i<j) { if(a[i][j]==0) { z++; } } else { o++; } } } if((r*c)==(z+o)) { printf("\n %d*%d Lower Matrix",r,c); } else { printf("\n %d*%d Not Lower Matrix",r,c); } return 0; }To download raw file Click Here
Enter the No of Rows:3 Enter the No of Columns:3 Enter the matrix Values:1 0 0 1 1 0 1 1 1 1 0 0 1 0 0 1 1 1 3*3 Lower Matrix
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions