Learn C ProgrammingLearn ProgrammingPrograms On ArraysResources

078. Write a program to accept a M x N matrix and print addition of lower triangular matrix elements in C language

By September 18, 2012 September 18th, 2019 No Comments
#include<stdio.h>
#include<conio.h>  
main()
{
	int i,j,m,a[5][5],sum=0;
	clrscr();
	printf("Enter order of matrix :\n");
	scanf("%d",&m);
	printf("Enter matrix elements.....\n");
	for(i=0;i<m;i++)
		for(j=0;j<m;j++)
			scanf("%d",&a[i][j]);
 
	for(i=0;i<m;i++)
		for(j=0;j<m;j++)
			if(i>j)
				sum=sum+a[i][j];
 
	printf("\nSum of lower triangular elements.....%d",sum);
	getch();
}

Leave a Reply

DEMO01